2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2010 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/module.h"
72 #include "magick/option.h"
73 #include "magick/paint.h"
74 #include "magick/profile.h"
75 #include "magick/property.h"
76 #include "magick/quantize.h"
77 #include "magick/quantum-private.h"
78 #include "magick/registry.h"
79 #include "magick/resize.h"
80 #include "magick/resource_.h"
81 #include "magick/segment.h"
82 #include "magick/shear.h"
83 #include "magick/signature.h"
84 #include "magick/static.h"
85 #include "magick/string_.h"
86 #include "magick/string-private.h"
87 #include "magick/transform.h"
88 #include "magick/threshold.h"
89 #include "magick/utility.h"
90 #if defined(MAGICKCORE_XML_DELEGATE)
91 # if defined(__WINDOWS__)
92 # if defined(__MINGW32__)
95 # include <win32config.h>
98 # include <libxml/parser.h>
99 # include <libxml/xmlmemory.h>
100 # include <libxml/parserInternals.h>
101 # include <libxml/xmlerror.h>
107 #define ThrowMSLException(severity,tag,reason) \
108 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
112 Typedef declaractions.
114 typedef struct _MSLGroupInfo
117 numImages; /* how many images are in this group */
120 typedef struct _MSLInfo
145 #if defined(MAGICKCORE_XML_DELEGATE)
155 Forward declarations.
157 #if defined(MAGICKCORE_XML_DELEGATE)
158 static MagickBooleanType
159 WriteMSLImage(const ImageInfo *,Image *);
161 static MagickBooleanType
162 SetMSLAttributes(MSLInfo *,const char *,const char *);
165 #if defined(MAGICKCORE_XML_DELEGATE)
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 % R e a d M S L I m a g e %
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
179 % It allocates the memory necessary for the new Image structure and returns a
180 % pointer to the new image.
182 % The format of the ReadMSLImage method is:
184 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
186 % A description of each parameter follows:
188 % o image_info: the image info.
190 % o exception: return any errors or warnings in this structure.
194 #if defined(__cplusplus) || defined(c_plusplus)
198 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
199 ExceptionInfo *exception)
213 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
214 sans_exception=AcquireExceptionInfo();
215 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
216 sans_exception=DestroyExceptionInfo(sans_exception);
217 if (image != (Image *) NULL)
219 read_info=CloneImageInfo(image_info);
220 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
221 image=ReadImage(read_info,exception);
222 read_info=DestroyImageInfo(read_info);
223 if (image != (Image *) NULL)
224 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
228 static int IsPathDirectory(const char *path)
236 if ((path == (const char *) NULL) || (*path == '\0'))
238 status=GetPathAttributes(path,&attributes);
239 if (status == MagickFalse)
241 if (S_ISDIR(attributes.st_mode) == 0)
246 static int MSLIsStandalone(void *context)
252 Is this document tagged standalone?
254 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
255 msl_info=(MSLInfo *) context;
256 return(msl_info->document->standalone == 1);
259 static int MSLHasInternalSubset(void *context)
265 Does this document has an internal subset?
267 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
268 " SAX.MSLHasInternalSubset()");
269 msl_info=(MSLInfo *) context;
270 return(msl_info->document->intSubset != NULL);
273 static int MSLHasExternalSubset(void *context)
279 Does this document has an external subset?
281 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
282 " SAX.MSLHasExternalSubset()");
283 msl_info=(MSLInfo *) context;
284 return(msl_info->document->extSubset != NULL);
287 static void MSLInternalSubset(void *context,const xmlChar *name,
288 const xmlChar *external_id,const xmlChar *system_id)
294 Does this document has an internal subset?
296 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
297 " SAX.internalSubset(%s %s %s)",name,
298 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
299 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
300 msl_info=(MSLInfo *) context;
301 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
304 static xmlParserInputPtr MSLResolveEntity(void *context,
305 const xmlChar *public_id,const xmlChar *system_id)
314 Special entity resolver, better left to the parser, it has more
315 context than the application layer. The default behaviour is to
316 not resolve the entities, in that case the ENTITY_REF nodes are
317 built in the structure (and the parameter values).
319 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
320 " SAX.resolveEntity(%s, %s)",
321 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
322 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
323 msl_info=(MSLInfo *) context;
324 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
325 public_id,msl_info->parser);
329 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
335 Get an entity by name.
337 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
338 " SAX.MSLGetEntity(%s)",(const char *) name);
339 msl_info=(MSLInfo *) context;
340 return(xmlGetDocEntity(msl_info->document,name));
343 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
349 Get a parameter entity by name.
351 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
352 " SAX.getParameterEntity(%s)",(const char *) name);
353 msl_info=(MSLInfo *) context;
354 return(xmlGetParameterEntity(msl_info->document,name));
357 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
358 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
364 An entity definition has been parsed.
366 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
367 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
368 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
369 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
371 msl_info=(MSLInfo *) context;
372 if (msl_info->parser->inSubset == 1)
373 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
376 if (msl_info->parser->inSubset == 2)
377 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
381 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
382 const xmlChar *name,int type,int value,const xmlChar *default_value,
383 xmlEnumerationPtr tree)
396 An attribute definition has been parsed.
398 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
399 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
401 msl_info=(MSLInfo *) context;
402 fullname=(xmlChar *) NULL;
403 prefix=(xmlChar *) NULL;
404 parser=msl_info->parser;
405 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
406 if (parser->inSubset == 1)
407 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
408 element,fullname,prefix,(xmlAttributeType) type,
409 (xmlAttributeDefault) value,default_value,tree);
411 if (parser->inSubset == 2)
412 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
413 element,fullname,prefix,(xmlAttributeType) type,
414 (xmlAttributeDefault) value,default_value,tree);
415 if (prefix != (xmlChar *) NULL)
417 if (fullname != (xmlChar *) NULL)
421 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
422 xmlElementContentPtr content)
431 An element definition has been parsed.
433 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
434 " SAX.elementDecl(%s, %d, ...)",name,type);
435 msl_info=(MSLInfo *) context;
436 parser=msl_info->parser;
437 if (parser->inSubset == 1)
438 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
439 name,(xmlElementTypeVal) type,content);
441 if (parser->inSubset == 2)
442 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
443 name,(xmlElementTypeVal) type,content);
446 static void MSLNotationDeclaration(void *context,const xmlChar *name,
447 const xmlChar *public_id,const xmlChar *system_id)
456 What to do when a notation declaration has been parsed.
458 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
459 " SAX.notationDecl(%s, %s, %s)",name,
460 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
461 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
462 msl_info=(MSLInfo *) context;
463 parser=msl_info->parser;
464 if (parser->inSubset == 1)
465 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
466 name,public_id,system_id);
468 if (parser->inSubset == 2)
469 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
470 name,public_id,system_id);
473 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
474 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
480 What to do when an unparsed entity declaration is parsed.
482 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
483 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
484 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
485 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
487 msl_info=(MSLInfo *) context;
488 (void) xmlAddDocEntity(msl_info->document,name,
489 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
493 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
499 Receive the document locator at startup, actually xmlDefaultSAXLocator.
501 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
502 " SAX.setDocumentLocator()\n");
504 msl_info=(MSLInfo *) context;
507 static void MSLStartDocument(void *context)
516 Called when the document start being processed.
518 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
519 " SAX.startDocument()");
520 msl_info=(MSLInfo *) context;
521 parser=msl_info->parser;
522 msl_info->document=xmlNewDoc(parser->version);
523 if (msl_info->document == (xmlDocPtr) NULL)
525 if (parser->encoding == NULL)
526 msl_info->document->encoding=NULL;
528 msl_info->document->encoding=xmlStrdup(parser->encoding);
529 msl_info->document->standalone=parser->standalone;
532 static void MSLEndDocument(void *context)
538 Called when the document end has been detected.
540 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
541 msl_info=(MSLInfo *) context;
542 if (msl_info->content != (char *) NULL)
543 msl_info->content=DestroyString(msl_info->content);
546 static void MSLPushImage(MSLInfo *msl_info,Image *image)
551 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
552 assert(msl_info != (MSLInfo *) NULL);
555 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
556 (n+1),sizeof(*msl_info->image_info));
557 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
558 (n+1),sizeof(*msl_info->draw_info));
559 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
560 (n+1),sizeof(*msl_info->attributes));
561 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
562 sizeof(*msl_info->image));
563 if ((msl_info->image_info == (ImageInfo **) NULL) ||
564 (msl_info->draw_info == (DrawInfo **) NULL) ||
565 (msl_info->attributes == (Image **) NULL) ||
566 (msl_info->image == (Image **) NULL))
567 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
568 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
569 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
570 msl_info->draw_info[n-1]);
571 if (image == (Image *) NULL)
572 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
574 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
575 msl_info->image[n]=(Image *) image;
576 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
577 (msl_info->attributes[n] == (Image *) NULL))
578 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
579 if (msl_info->number_groups != 0)
580 msl_info->group_info[msl_info->number_groups-1].numImages++;
583 static void MSLPopImage(MSLInfo *msl_info)
585 if (msl_info->number_groups != 0)
587 if (msl_info->image[msl_info->n] != (Image *) NULL)
588 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
589 msl_info->attributes[msl_info->n]=DestroyImage(
590 msl_info->attributes[msl_info->n]);
591 msl_info->image_info[msl_info->n]=DestroyImageInfo(
592 msl_info->image_info[msl_info->n]);
596 static void MSLStartElement(void *context,const xmlChar *tag,
597 const xmlChar **attributes)
653 Called when an opening tag has been processed.
655 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
656 " SAX.startElement(%s",tag);
657 GetExceptionInfo(&exception);
658 msl_info=(MSLInfo *) context;
660 keyword=(const char *) NULL;
662 SetGeometryInfo(&geometry_info);
663 channel=DefaultChannels;
669 if (LocaleCompare((const char *) tag,"add-noise") == 0)
680 if (msl_info->image[n] == (Image *) NULL)
682 ThrowMSLException(OptionError,"NoImagesDefined",
687 if (attributes != (const xmlChar **) NULL)
688 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
690 keyword=(const char *) attributes[i++];
691 attribute=InterpretImageProperties(msl_info->image_info[n],
692 msl_info->attributes[n],(const char *) attributes[i]);
693 CloneString(&value,attribute);
699 if (LocaleCompare(keyword,"channel") == 0)
701 option=ParseChannelOption(value);
703 ThrowMSLException(OptionError,"UnrecognizedChannelType",
705 channel=(ChannelType) option;
708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
715 if (LocaleCompare(keyword,"noise") == 0)
717 option=ParseMagickOption(MagickNoiseOptions,MagickFalse,
720 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
722 noise=(NoiseType) option;
725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
737 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
738 &msl_info->image[n]->exception);
739 if (noise_image == (Image *) NULL)
741 msl_info->image[n]=DestroyImage(msl_info->image[n]);
742 msl_info->image[n]=noise_image;
745 if (LocaleCompare((const char *) tag,"annotate") == 0)
753 if (msl_info->image[n] == (Image *) NULL)
755 ThrowMSLException(OptionError,"NoImagesDefined",
759 draw_info=CloneDrawInfo(msl_info->image_info[n],
760 msl_info->draw_info[n]);
762 current=draw_info->affine;
763 GetAffineMatrix(&affine);
764 if (attributes != (const xmlChar **) NULL)
765 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
767 keyword=(const char *) attributes[i++];
768 attribute=InterpretImageProperties(msl_info->image_info[n],
769 msl_info->attributes[n],(const char *) attributes[i]);
770 CloneString(&value,attribute);
776 if (LocaleCompare(keyword,"affine") == 0)
782 draw_info->affine.sx=strtod(p,&p);
785 draw_info->affine.rx=strtod(p,&p);
788 draw_info->affine.ry=strtod(p,&p);
791 draw_info->affine.sy=strtod(p,&p);
794 draw_info->affine.tx=strtod(p,&p);
797 draw_info->affine.ty=strtod(p,&p);
800 if (LocaleCompare(keyword,"align") == 0)
802 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
805 ThrowMSLException(OptionError,"UnrecognizedAlignType",
807 draw_info->align=(AlignType) option;
810 if (LocaleCompare(keyword,"antialias") == 0)
812 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
815 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
817 draw_info->stroke_antialias=(MagickBooleanType) option;
818 draw_info->text_antialias=(MagickBooleanType) option;
821 ThrowMSLException(OptionError,"UnrecognizedAttribute",
828 if (LocaleCompare(keyword,"density") == 0)
830 CloneString(&draw_info->density,value);
833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
840 if (LocaleCompare(keyword,"encoding") == 0)
842 CloneString(&draw_info->encoding,value);
845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
852 if (LocaleCompare(keyword, "fill") == 0)
854 (void) QueryColorDatabase(value,&draw_info->fill,
858 if (LocaleCompare(keyword,"family") == 0)
860 CloneString(&draw_info->family,value);
863 if (LocaleCompare(keyword,"font") == 0)
865 CloneString(&draw_info->font,value);
868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
875 if (LocaleCompare(keyword,"geometry") == 0)
877 flags=ParsePageGeometry(msl_info->image[n],value,
878 &geometry,&exception);
879 if ((flags & HeightValue) == 0)
880 geometry.height=geometry.width;
883 if (LocaleCompare(keyword,"gravity") == 0)
885 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
888 ThrowMSLException(OptionError,"UnrecognizedGravityType",
890 draw_info->gravity=(GravityType) option;
893 ThrowMSLException(OptionError,"UnrecognizedAttribute",
900 if (LocaleCompare(keyword,"pointsize") == 0)
902 draw_info->pointsize=StringToDouble(value);
905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
912 if (LocaleCompare(keyword,"rotate") == 0)
914 angle=StringToDouble(value);
915 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
916 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
917 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
918 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
921 ThrowMSLException(OptionError,"UnrecognizedAttribute",
928 if (LocaleCompare(keyword,"scale") == 0)
930 flags=ParseGeometry(value,&geometry_info);
931 if ((flags & SigmaValue) == 0)
932 geometry_info.sigma=1.0;
933 affine.sx=geometry_info.rho;
934 affine.sy=geometry_info.sigma;
937 if (LocaleCompare(keyword,"skewX") == 0)
939 angle=StringToDouble(value);
940 affine.ry=tan(DegreesToRadians(fmod((double) angle,
944 if (LocaleCompare(keyword,"skewY") == 0)
946 angle=StringToDouble(value);
947 affine.rx=tan(DegreesToRadians(fmod((double) angle,
951 if (LocaleCompare(keyword,"stretch") == 0)
953 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
956 ThrowMSLException(OptionError,"UnrecognizedStretchType",
958 draw_info->stretch=(StretchType) option;
961 if (LocaleCompare(keyword, "stroke") == 0)
963 (void) QueryColorDatabase(value,&draw_info->stroke,
967 if (LocaleCompare(keyword,"strokewidth") == 0)
969 draw_info->stroke_width=StringToLong(value);
972 if (LocaleCompare(keyword,"style") == 0)
974 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
977 ThrowMSLException(OptionError,"UnrecognizedStyleType",
979 draw_info->style=(StyleType) option;
982 ThrowMSLException(OptionError,"UnrecognizedAttribute",
989 if (LocaleCompare(keyword,"text") == 0)
991 CloneString(&draw_info->text,value);
994 if (LocaleCompare(keyword,"translate") == 0)
996 flags=ParseGeometry(value,&geometry_info);
997 if ((flags & SigmaValue) == 0)
998 geometry_info.sigma=1.0;
999 affine.tx=geometry_info.rho;
1000 affine.ty=geometry_info.sigma;
1003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1010 if (LocaleCompare(keyword, "undercolor") == 0)
1012 (void) QueryColorDatabase(value,&draw_info->undercolor,
1016 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1023 if (LocaleCompare(keyword,"weight") == 0)
1025 draw_info->weight=StringToLong(value);
1028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1035 if (LocaleCompare(keyword,"x") == 0)
1037 geometry.x=StringToLong(value);
1040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1047 if (LocaleCompare(keyword,"y") == 0)
1049 geometry.y=StringToLong(value);
1052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1064 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
1065 geometry.width,geometry.height,geometry.x,geometry.y);
1066 CloneString(&draw_info->geometry,text);
1067 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1068 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1069 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1070 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1071 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
1073 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
1075 (void) AnnotateImage(msl_info->image[n],draw_info);
1076 draw_info=DestroyDrawInfo(draw_info);
1079 if (LocaleCompare((const char *) tag,"append") == 0)
1087 if (msl_info->image[n] == (Image *) NULL)
1089 ThrowMSLException(OptionError,"NoImagesDefined",
1090 (const char *) tag);
1094 if (attributes != (const xmlChar **) NULL)
1095 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1097 keyword=(const char *) attributes[i++];
1098 attribute=InterpretImageProperties(msl_info->image_info[n],
1099 msl_info->attributes[n],(const char *) attributes[i]);
1100 CloneString(&value,attribute);
1106 if (LocaleCompare(keyword,"stack") == 0)
1108 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1111 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1113 stack=(MagickBooleanType) option;
1116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1128 append_image=AppendImages(msl_info->image[n],stack,
1129 &msl_info->image[n]->exception);
1130 if (append_image == (Image *) NULL)
1132 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1133 msl_info->image[n]=append_image;
1136 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1142 if (LocaleCompare((const char *) tag,"blur") == 0)
1150 if (msl_info->image[n] == (Image *) NULL)
1152 ThrowMSLException(OptionError,"NoImagesDefined",
1153 (const char *) tag);
1156 if (attributes != (const xmlChar **) NULL)
1157 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1159 keyword=(const char *) attributes[i++];
1160 attribute=InterpretImageProperties(msl_info->image_info[n],
1161 msl_info->attributes[n],(const char *) attributes[i]);
1162 CloneString(&value,attribute);
1168 if (LocaleCompare(keyword,"channel") == 0)
1170 option=ParseChannelOption(value);
1172 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1174 channel=(ChannelType) option;
1177 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1184 if (LocaleCompare(keyword,"geometry") == 0)
1186 flags=ParseGeometry(value,&geometry_info);
1187 if ((flags & SigmaValue) == 0)
1188 geometry_info.sigma=1.0;
1191 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1198 if (LocaleCompare(keyword,"radius") == 0)
1200 geometry_info.rho=StringToDouble(value);
1203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1210 if (LocaleCompare(keyword,"sigma") == 0)
1212 geometry_info.sigma=StringToLong(value);
1215 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1227 blur_image=BlurImageChannel(msl_info->image[n],channel,
1228 geometry_info.rho,geometry_info.sigma,
1229 &msl_info->image[n]->exception);
1230 if (blur_image == (Image *) NULL)
1232 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1233 msl_info->image[n]=blur_image;
1236 if (LocaleCompare((const char *) tag,"border") == 0)
1244 if (msl_info->image[n] == (Image *) NULL)
1246 ThrowMSLException(OptionError,"NoImagesDefined",
1247 (const char *) tag);
1250 SetGeometry(msl_info->image[n],&geometry);
1251 if (attributes != (const xmlChar **) NULL)
1252 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1254 keyword=(const char *) attributes[i++];
1255 attribute=InterpretImageProperties(msl_info->image_info[n],
1256 msl_info->attributes[n],(const char *) attributes[i]);
1257 CloneString(&value,attribute);
1263 if (LocaleCompare(keyword,"compose") == 0)
1265 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1268 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1270 msl_info->image[n]->compose=(CompositeOperator) option;
1273 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1280 if (LocaleCompare(keyword, "fill") == 0)
1282 (void) QueryColorDatabase(value,
1283 &msl_info->image[n]->border_color,&exception);
1286 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1293 if (LocaleCompare(keyword,"geometry") == 0)
1295 flags=ParsePageGeometry(msl_info->image[n],value,
1296 &geometry,&exception);
1297 if ((flags & HeightValue) == 0)
1298 geometry.height=geometry.width;
1301 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1308 if (LocaleCompare(keyword,"height") == 0)
1310 geometry.height=StringToLong(value);
1313 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1320 if (LocaleCompare(keyword,"width") == 0)
1322 geometry.width=StringToLong(value);
1325 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1337 border_image=BorderImage(msl_info->image[n],&geometry,
1338 &msl_info->image[n]->exception);
1339 if (border_image == (Image *) NULL)
1341 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1342 msl_info->image[n]=border_image;
1345 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1350 if (LocaleCompare((const char *) tag,"colorize") == 0)
1353 opacity[MaxTextExtent];
1364 if (msl_info->image[n] == (Image *) NULL)
1366 ThrowMSLException(OptionError,"NoImagesDefined",
1367 (const char *) tag);
1370 target=msl_info->image[n]->background_color;
1371 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1372 if (attributes != (const xmlChar **) NULL)
1373 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1375 keyword=(const char *) attributes[i++];
1376 attribute=InterpretImageProperties(msl_info->image_info[n],
1377 msl_info->attributes[n],(const char *) attributes[i]);
1378 CloneString(&value,attribute);
1384 if (LocaleCompare(keyword,"fill") == 0)
1386 (void) QueryColorDatabase(value,&target,
1387 &msl_info->image[n]->exception);
1390 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1397 if (LocaleCompare(keyword,"opacity") == 0)
1399 (void) CopyMagickString(opacity,value,MaxTextExtent);
1402 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1415 &msl_info->image[n]->exception);
1416 if (colorize_image == (Image *) NULL)
1418 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1419 msl_info->image[n]=colorize_image;
1422 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1424 double radius = 0.0,
1427 if (msl_info->image[n] == (Image *) NULL)
1429 ThrowMSLException(OptionError,"NoImagesDefined",
1430 (const char *) tag);
1434 NOTE: charcoal can have no attributes, since we use all the defaults!
1436 if (attributes != (const xmlChar **) NULL)
1438 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1440 keyword=(const char *) attributes[i++];
1441 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1442 msl_info->attributes[n],(const char *) attributes[i]));
1448 if (LocaleCompare(keyword, "radius") == 0)
1450 radius = StringToDouble( value );
1453 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1459 if (LocaleCompare(keyword,"sigma") == 0)
1461 sigma = StringToLong( value );
1464 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1483 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1484 &msl_info->image[n]->exception);
1485 if (newImage == (Image *) NULL)
1487 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1488 msl_info->image[n]=newImage;
1492 if (LocaleCompare((const char *) tag,"chop") == 0)
1500 if (msl_info->image[n] == (Image *) NULL)
1502 ThrowMSLException(OptionError,"NoImagesDefined",
1503 (const char *) tag);
1506 SetGeometry(msl_info->image[n],&geometry);
1507 if (attributes != (const xmlChar **) NULL)
1508 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1510 keyword=(const char *) attributes[i++];
1511 attribute=InterpretImageProperties(msl_info->image_info[n],
1512 msl_info->attributes[n],(const char *) attributes[i]);
1513 CloneString(&value,attribute);
1519 if (LocaleCompare(keyword,"geometry") == 0)
1521 flags=ParsePageGeometry(msl_info->image[n],value,
1522 &geometry,&exception);
1523 if ((flags & HeightValue) == 0)
1524 geometry.height=geometry.width;
1527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1534 if (LocaleCompare(keyword,"height") == 0)
1536 geometry.height=StringToLong(value);
1539 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1546 if (LocaleCompare(keyword,"width") == 0)
1548 geometry.width=StringToLong(value);
1551 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1558 if (LocaleCompare(keyword,"x") == 0)
1560 geometry.x=StringToLong(value);
1563 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1570 if (LocaleCompare(keyword,"y") == 0)
1572 geometry.y=StringToLong(value);
1575 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1587 chop_image=ChopImage(msl_info->image[n],&geometry,
1588 &msl_info->image[n]->exception);
1589 if (chop_image == (Image *) NULL)
1591 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1592 msl_info->image[n]=chop_image;
1595 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1604 Color floodfill image.
1606 if (msl_info->image[n] == (Image *) NULL)
1608 ThrowMSLException(OptionError,"NoImagesDefined",
1609 (const char *) tag);
1612 draw_info=CloneDrawInfo(msl_info->image_info[n],
1613 msl_info->draw_info[n]);
1614 SetGeometry(msl_info->image[n],&geometry);
1615 paint_method=FloodfillMethod;
1616 if (attributes != (const xmlChar **) NULL)
1617 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1619 keyword=(const char *) attributes[i++];
1620 attribute=InterpretImageProperties(msl_info->image_info[n],
1621 msl_info->attributes[n],(const char *) attributes[i]);
1622 CloneString(&value,attribute);
1628 if (LocaleCompare(keyword,"bordercolor") == 0)
1630 (void) QueryMagickColor(value,&target,&exception);
1631 paint_method=FillToBorderMethod;
1634 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1641 if (LocaleCompare(keyword,"fill") == 0)
1643 (void) QueryColorDatabase(value,&draw_info->fill,
1647 if (LocaleCompare(keyword,"fuzz") == 0)
1649 msl_info->image[n]->fuzz=StringToDouble(value);
1652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1659 if (LocaleCompare(keyword,"geometry") == 0)
1661 flags=ParsePageGeometry(msl_info->image[n],value,
1662 &geometry,&exception);
1663 if ((flags & HeightValue) == 0)
1664 geometry.height=geometry.width;
1665 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1666 geometry.x,geometry.y,&target,&exception);
1669 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1676 if (LocaleCompare(keyword,"x") == 0)
1678 geometry.x=StringToLong(value);
1679 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1680 geometry.x,geometry.y,&target,&exception);
1683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1690 if (LocaleCompare(keyword,"y") == 0)
1692 geometry.y=StringToLong(value);
1693 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1694 geometry.x,geometry.y,&target,&exception);
1697 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1703 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1709 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1710 draw_info,&target,geometry.x,geometry.y,
1711 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1712 draw_info=DestroyDrawInfo(draw_info);
1715 if (LocaleCompare((const char *) tag,"comment") == 0)
1717 if (LocaleCompare((const char *) tag,"composite") == 0)
1720 composite_geometry[MaxTextExtent];
1735 if (msl_info->image[n] == (Image *) NULL)
1737 ThrowMSLException(OptionError,"NoImagesDefined",
1738 (const char *) tag);
1741 composite_image=NewImageList();
1742 compose=OverCompositeOp;
1743 if (attributes != (const xmlChar **) NULL)
1744 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1746 keyword=(const char *) attributes[i++];
1747 attribute=InterpretImageProperties(msl_info->image_info[n],
1748 msl_info->attributes[n],(const char *) attributes[i]);
1749 CloneString(&value,attribute);
1755 if (LocaleCompare(keyword,"compose") == 0)
1757 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1760 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1762 compose=(CompositeOperator) option;
1770 if (LocaleCompare(keyword,"image") == 0)
1771 for (j=0; j < msl_info->n; j++)
1776 attribute=GetImageProperty(msl_info->attributes[j],"id");
1777 if ((attribute != (const char *) NULL) &&
1778 (LocaleCompare(attribute,value) == 0))
1780 composite_image=CloneImage(msl_info->image[j],0,0,
1781 MagickFalse,&exception);
1791 if (composite_image == (Image *) NULL)
1793 rotate_image=NewImageList();
1794 SetGeometry(msl_info->image[n],&geometry);
1795 if (attributes != (const xmlChar **) NULL)
1796 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1798 keyword=(const char *) attributes[i++];
1799 attribute=InterpretImageProperties(msl_info->image_info[n],
1800 msl_info->attributes[n],(const char *) attributes[i]);
1801 CloneString(&value,attribute);
1807 if (LocaleCompare(keyword,"blend") == 0)
1809 (void) SetImageArtifact(composite_image,
1810 "compose:args",value);
1813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1820 if (LocaleCompare(keyword,"channel") == 0)
1822 option=ParseChannelOption(value);
1824 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1826 channel=(ChannelType) option;
1829 if (LocaleCompare(keyword, "color") == 0)
1831 (void) QueryColorDatabase(value,
1832 &composite_image->background_color,&exception);
1835 if (LocaleCompare(keyword,"compose") == 0)
1837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1844 if (LocaleCompare(keyword,"geometry") == 0)
1846 flags=ParsePageGeometry(msl_info->image[n],value,
1847 &geometry,&exception);
1848 if ((flags & HeightValue) == 0)
1849 geometry.height=geometry.width;
1850 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1851 geometry.y,&target,&exception);
1854 if (LocaleCompare(keyword,"gravity") == 0)
1856 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
1859 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1861 msl_info->image[n]->gravity=(GravityType) option;
1864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1871 if (LocaleCompare(keyword,"image") == 0)
1873 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1880 if (LocaleCompare(keyword,"mask") == 0)
1881 for (j=0; j < msl_info->n; j++)
1886 attribute=GetImageProperty(msl_info->attributes[j],"id");
1887 if ((attribute != (const char *) NULL) &&
1888 (LocaleCompare(value,value) == 0))
1890 SetImageType(composite_image,TrueColorMatteType);
1891 (void) CompositeImage(composite_image,
1892 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1896 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1903 if (LocaleCompare(keyword,"opacity") == 0)
1912 register PixelPacket
1918 opacity=QuantumRange-StringToLong(value);
1919 if (compose != DissolveCompositeOp)
1921 (void) SetImageOpacity(composite_image,(Quantum)
1925 (void) SetImageArtifact(msl_info->image[n],
1926 "compose:args",value);
1927 if (composite_image->matte != MagickTrue)
1928 (void) SetImageOpacity(composite_image,OpaqueOpacity);
1929 composite_view=AcquireCacheView(composite_image);
1930 for (y=0; y < (long) composite_image->rows ; y++)
1932 q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
1933 composite_image->columns,1,&exception);
1934 for (x=0; x < (long) composite_image->columns; x++)
1936 if (q->opacity == OpaqueOpacity)
1937 q->opacity=ClampToQuantum(opacity);
1940 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1943 composite_view=DestroyCacheView(composite_view);
1946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1953 if (LocaleCompare(keyword,"rotate") == 0)
1955 rotate_image=RotateImage(composite_image,StringToDouble(value),
1959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1966 if (LocaleCompare(keyword,"tile") == 0)
1971 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1974 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1976 tile=(MagickBooleanType) option;
1977 if (rotate_image != (Image *) NULL)
1978 (void) SetImageArtifact(rotate_image,
1979 "compose:outside-overlay","false");
1981 (void) SetImageArtifact(composite_image,
1982 "compose:outside-overlay","false");
1983 image=msl_info->image[n];
1984 height=composite_image->rows;
1985 width=composite_image->columns;
1986 for (y=0; y < (long) image->rows; y+=height)
1987 for (x=0; x < (long) image->columns; x+=width)
1989 if (rotate_image != (Image *) NULL)
1990 (void) CompositeImage(image,compose,rotate_image,
1993 (void) CompositeImage(image,compose,
1994 composite_image,x,y);
1996 if (rotate_image != (Image *) NULL)
1997 rotate_image=DestroyImage(rotate_image);
2000 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2007 if (LocaleCompare(keyword,"x") == 0)
2009 geometry.x=StringToLong(value);
2010 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2011 geometry.y,&target,&exception);
2014 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2021 if (LocaleCompare(keyword,"y") == 0)
2023 geometry.y=StringToLong(value);
2024 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2025 geometry.y,&target,&exception);
2028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2040 image=msl_info->image[n];
2041 (void) FormatMagickString(composite_geometry,MaxTextExtent,
2042 "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
2043 geometry.x,geometry.y);
2044 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2046 if (rotate_image == (Image *) NULL)
2047 CompositeImageChannel(image,channel,compose,composite_image,
2048 geometry.x,geometry.y);
2054 geometry.x-=(long) (rotate_image->columns-
2055 composite_image->columns)/2;
2056 geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
2057 CompositeImageChannel(image,channel,compose,rotate_image,
2058 geometry.x,geometry.y);
2059 rotate_image=DestroyImage(rotate_image);
2061 composite_image=DestroyImage(composite_image);
2064 if (LocaleCompare((const char *) tag,"contrast") == 0)
2072 if (msl_info->image[n] == (Image *) NULL)
2074 ThrowMSLException(OptionError,"NoImagesDefined",
2075 (const char *) tag);
2078 sharpen=MagickFalse;
2079 if (attributes != (const xmlChar **) NULL)
2080 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2082 keyword=(const char *) attributes[i++];
2083 attribute=InterpretImageProperties(msl_info->image_info[n],
2084 msl_info->attributes[n],(const char *) attributes[i]);
2085 CloneString(&value,attribute);
2091 if (LocaleCompare(keyword,"sharpen") == 0)
2093 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2096 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2098 sharpen=(MagickBooleanType) option;
2101 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2113 (void) ContrastImage(msl_info->image[n],sharpen);
2116 if (LocaleCompare((const char *) tag,"crop") == 0)
2124 if (msl_info->image[n] == (Image *) NULL)
2126 ThrowMSLException(OptionError,"NoImagesDefined",
2127 (const char *) tag);
2130 SetGeometry(msl_info->image[n],&geometry);
2131 if (attributes != (const xmlChar **) NULL)
2132 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2134 keyword=(const char *) attributes[i++];
2135 attribute=InterpretImageProperties(msl_info->image_info[n],
2136 msl_info->attributes[n],(const char *) attributes[i]);
2137 CloneString(&value,attribute);
2143 if (LocaleCompare(keyword,"geometry") == 0)
2145 flags=ParsePageGeometry(msl_info->image[n],value,
2146 &geometry,&exception);
2147 if ((flags & HeightValue) == 0)
2148 geometry.height=geometry.width;
2151 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2158 if (LocaleCompare(keyword,"height") == 0)
2160 geometry.height=StringToLong(value);
2163 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2170 if (LocaleCompare(keyword,"width") == 0)
2172 geometry.width=StringToLong(value);
2175 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2182 if (LocaleCompare(keyword,"x") == 0)
2184 geometry.x=StringToLong(value);
2187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2194 if (LocaleCompare(keyword,"y") == 0)
2196 geometry.y=StringToLong(value);
2199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2211 crop_image=CropImage(msl_info->image[n],&geometry,
2212 &msl_info->image[n]->exception);
2213 if (crop_image == (Image *) NULL)
2215 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2216 msl_info->image[n]=crop_image;
2219 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2225 Cycle-colormap image.
2227 if (msl_info->image[n] == (Image *) NULL)
2229 ThrowMSLException(OptionError,"NoImagesDefined",
2230 (const char *) tag);
2234 if (attributes != (const xmlChar **) NULL)
2235 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2237 keyword=(const char *) attributes[i++];
2238 attribute=InterpretImageProperties(msl_info->image_info[n],
2239 msl_info->attributes[n],(const char *) attributes[i]);
2240 CloneString(&value,attribute);
2246 if (LocaleCompare(keyword,"display") == 0)
2248 display=StringToLong(value);
2251 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2257 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2263 (void) CycleColormapImage(msl_info->image[n],display);
2266 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2271 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2279 if (msl_info->image[n] == (Image *) NULL)
2281 ThrowMSLException(OptionError,"NoImagesDefined",
2282 (const char *) tag);
2285 if (attributes != (const xmlChar **) NULL)
2286 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2288 keyword=(const char *) attributes[i++];
2289 attribute=InterpretImageProperties(msl_info->image_info[n],
2290 msl_info->attributes[n],(const char *) attributes[i]);
2291 CloneString(&value,attribute);
2292 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2294 despeckle_image=DespeckleImage(msl_info->image[n],
2295 &msl_info->image[n]->exception);
2296 if (despeckle_image == (Image *) NULL)
2298 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2299 msl_info->image[n]=despeckle_image;
2302 if (LocaleCompare((const char *) tag,"display") == 0)
2304 if (msl_info->image[n] == (Image *) NULL)
2306 ThrowMSLException(OptionError,"NoImagesDefined",
2307 (const char *) tag);
2310 if (attributes != (const xmlChar **) NULL)
2311 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2313 keyword=(const char *) attributes[i++];
2314 attribute=InterpretImageProperties(msl_info->image_info[n],
2315 msl_info->attributes[n],(const char *) attributes[i]);
2316 CloneString(&value,attribute);
2321 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2327 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2330 if (LocaleCompare((const char *) tag,"draw") == 0)
2333 text[MaxTextExtent];
2338 if (msl_info->image[n] == (Image *) NULL)
2340 ThrowMSLException(OptionError,"NoImagesDefined",
2341 (const char *) tag);
2344 draw_info=CloneDrawInfo(msl_info->image_info[n],
2345 msl_info->draw_info[n]);
2347 current=draw_info->affine;
2348 GetAffineMatrix(&affine);
2349 if (attributes != (const xmlChar **) NULL)
2350 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2352 keyword=(const char *) attributes[i++];
2353 attribute=InterpretImageProperties(msl_info->image_info[n],
2354 msl_info->attributes[n],(const char *) attributes[i]);
2355 CloneString(&value,attribute);
2361 if (LocaleCompare(keyword,"affine") == 0)
2367 draw_info->affine.sx=strtod(p,&p);
2370 draw_info->affine.rx=strtod(p,&p);
2373 draw_info->affine.ry=strtod(p,&p);
2376 draw_info->affine.sy=strtod(p,&p);
2379 draw_info->affine.tx=strtod(p,&p);
2382 draw_info->affine.ty=strtod(p,&p);
2385 if (LocaleCompare(keyword,"align") == 0)
2387 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
2390 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2392 draw_info->align=(AlignType) option;
2395 if (LocaleCompare(keyword,"antialias") == 0)
2397 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2400 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2402 draw_info->stroke_antialias=(MagickBooleanType) option;
2403 draw_info->text_antialias=(MagickBooleanType) option;
2406 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2413 if (LocaleCompare(keyword,"density") == 0)
2415 CloneString(&draw_info->density,value);
2418 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2425 if (LocaleCompare(keyword,"encoding") == 0)
2427 CloneString(&draw_info->encoding,value);
2430 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2437 if (LocaleCompare(keyword, "fill") == 0)
2439 (void) QueryColorDatabase(value,&draw_info->fill,
2443 if (LocaleCompare(keyword,"family") == 0)
2445 CloneString(&draw_info->family,value);
2448 if (LocaleCompare(keyword,"font") == 0)
2450 CloneString(&draw_info->font,value);
2453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2460 if (LocaleCompare(keyword,"geometry") == 0)
2462 flags=ParsePageGeometry(msl_info->image[n],value,
2463 &geometry,&exception);
2464 if ((flags & HeightValue) == 0)
2465 geometry.height=geometry.width;
2468 if (LocaleCompare(keyword,"gravity") == 0)
2470 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
2473 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2475 draw_info->gravity=(GravityType) option;
2478 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2485 if (LocaleCompare(keyword,"primitive") == 0)
2487 CloneString(&draw_info->primitive,value);
2490 if (LocaleCompare(keyword,"pointsize") == 0)
2492 draw_info->pointsize=StringToDouble(value);
2495 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2502 if (LocaleCompare(keyword,"rotate") == 0)
2504 angle=StringToDouble(value);
2505 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2506 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2507 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2508 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2511 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2518 if (LocaleCompare(keyword,"scale") == 0)
2520 flags=ParseGeometry(value,&geometry_info);
2521 if ((flags & SigmaValue) == 0)
2522 geometry_info.sigma=1.0;
2523 affine.sx=geometry_info.rho;
2524 affine.sy=geometry_info.sigma;
2527 if (LocaleCompare(keyword,"skewX") == 0)
2529 angle=StringToDouble(value);
2530 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2533 if (LocaleCompare(keyword,"skewY") == 0)
2535 angle=StringToDouble(value);
2536 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2539 if (LocaleCompare(keyword,"stretch") == 0)
2541 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
2544 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2546 draw_info->stretch=(StretchType) option;
2549 if (LocaleCompare(keyword, "stroke") == 0)
2551 (void) QueryColorDatabase(value,&draw_info->stroke,
2555 if (LocaleCompare(keyword,"strokewidth") == 0)
2557 draw_info->stroke_width=StringToLong(value);
2560 if (LocaleCompare(keyword,"style") == 0)
2562 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
2565 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2567 draw_info->style=(StyleType) option;
2570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2577 if (LocaleCompare(keyword,"text") == 0)
2579 CloneString(&draw_info->text,value);
2582 if (LocaleCompare(keyword,"translate") == 0)
2584 flags=ParseGeometry(value,&geometry_info);
2585 if ((flags & SigmaValue) == 0)
2586 geometry_info.sigma=1.0;
2587 affine.tx=geometry_info.rho;
2588 affine.ty=geometry_info.sigma;
2591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2598 if (LocaleCompare(keyword, "undercolor") == 0)
2600 (void) QueryColorDatabase(value,&draw_info->undercolor,
2604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2611 if (LocaleCompare(keyword,"weight") == 0)
2613 draw_info->weight=StringToLong(value);
2616 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2623 if (LocaleCompare(keyword,"x") == 0)
2625 geometry.x=StringToLong(value);
2628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2635 if (LocaleCompare(keyword,"y") == 0)
2637 geometry.y=StringToLong(value);
2640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2646 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2652 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
2653 geometry.width,geometry.height,geometry.x,geometry.y);
2654 CloneString(&draw_info->geometry,text);
2655 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
2656 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
2657 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
2658 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
2659 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
2661 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
2663 (void) DrawImage(msl_info->image[n],draw_info);
2664 draw_info=DestroyDrawInfo(draw_info);
2667 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2672 if (LocaleCompare((const char *) tag,"edge") == 0)
2680 if (msl_info->image[n] == (Image *) NULL)
2682 ThrowMSLException(OptionError,"NoImagesDefined",
2683 (const char *) tag);
2686 if (attributes != (const xmlChar **) NULL)
2687 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2689 keyword=(const char *) attributes[i++];
2690 attribute=InterpretImageProperties(msl_info->image_info[n],
2691 msl_info->attributes[n],(const char *) attributes[i]);
2692 CloneString(&value,attribute);
2698 if (LocaleCompare(keyword,"geometry") == 0)
2700 flags=ParseGeometry(value,&geometry_info);
2701 if ((flags & SigmaValue) == 0)
2702 geometry_info.sigma=1.0;
2705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2712 if (LocaleCompare(keyword,"radius") == 0)
2714 geometry_info.rho=StringToDouble(value);
2717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2729 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2730 &msl_info->image[n]->exception);
2731 if (edge_image == (Image *) NULL)
2733 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2734 msl_info->image[n]=edge_image;
2737 if (LocaleCompare((const char *) tag,"emboss") == 0)
2745 if (msl_info->image[n] == (Image *) NULL)
2747 ThrowMSLException(OptionError,"NoImagesDefined",
2748 (const char *) tag);
2751 if (attributes != (const xmlChar **) NULL)
2752 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2754 keyword=(const char *) attributes[i++];
2755 attribute=InterpretImageProperties(msl_info->image_info[n],
2756 msl_info->attributes[n],(const char *) attributes[i]);
2757 CloneString(&value,attribute);
2763 if (LocaleCompare(keyword,"geometry") == 0)
2765 flags=ParseGeometry(value,&geometry_info);
2766 if ((flags & SigmaValue) == 0)
2767 geometry_info.sigma=1.0;
2770 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2777 if (LocaleCompare(keyword,"radius") == 0)
2779 geometry_info.rho=StringToDouble(value);
2782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2789 if (LocaleCompare(keyword,"sigma") == 0)
2791 geometry_info.sigma=StringToLong(value);
2794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2806 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2807 geometry_info.sigma,&msl_info->image[n]->exception);
2808 if (emboss_image == (Image *) NULL)
2810 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2811 msl_info->image[n]=emboss_image;
2814 if (LocaleCompare((const char *) tag,"enhance") == 0)
2822 if (msl_info->image[n] == (Image *) NULL)
2824 ThrowMSLException(OptionError,"NoImagesDefined",
2825 (const char *) tag);
2828 if (attributes != (const xmlChar **) NULL)
2829 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2831 keyword=(const char *) attributes[i++];
2832 attribute=InterpretImageProperties(msl_info->image_info[n],
2833 msl_info->attributes[n],(const char *) attributes[i]);
2834 CloneString(&value,attribute);
2835 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2837 enhance_image=EnhanceImage(msl_info->image[n],
2838 &msl_info->image[n]->exception);
2839 if (enhance_image == (Image *) NULL)
2841 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2842 msl_info->image[n]=enhance_image;
2845 if (LocaleCompare((const char *) tag,"equalize") == 0)
2850 if (msl_info->image[n] == (Image *) NULL)
2852 ThrowMSLException(OptionError,"NoImagesDefined",
2853 (const char *) tag);
2856 if (attributes != (const xmlChar **) NULL)
2857 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2859 keyword=(const char *) attributes[i++];
2860 attribute=InterpretImageProperties(msl_info->image_info[n],
2861 msl_info->attributes[n],(const char *) attributes[i]);
2862 CloneString(&value,attribute);
2867 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2873 (void) EqualizeImage(msl_info->image[n]);
2876 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2881 if (LocaleCompare((const char *) tag, "flatten") == 0)
2883 if (msl_info->image[n] == (Image *) NULL)
2885 ThrowMSLException(OptionError,"NoImagesDefined",
2886 (const char *) tag);
2890 /* no attributes here */
2892 /* process the image */
2897 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2898 &msl_info->image[n]->exception);
2899 if (newImage == (Image *) NULL)
2901 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2902 msl_info->image[n]=newImage;
2906 if (LocaleCompare((const char *) tag,"flip") == 0)
2914 if (msl_info->image[n] == (Image *) NULL)
2916 ThrowMSLException(OptionError,"NoImagesDefined",
2917 (const char *) tag);
2920 if (attributes != (const xmlChar **) NULL)
2921 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2923 keyword=(const char *) attributes[i++];
2924 attribute=InterpretImageProperties(msl_info->image_info[n],
2925 msl_info->attributes[n],(const char *) attributes[i]);
2926 CloneString(&value,attribute);
2927 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2929 flip_image=FlipImage(msl_info->image[n],
2930 &msl_info->image[n]->exception);
2931 if (flip_image == (Image *) NULL)
2933 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2934 msl_info->image[n]=flip_image;
2937 if (LocaleCompare((const char *) tag,"flop") == 0)
2945 if (msl_info->image[n] == (Image *) NULL)
2947 ThrowMSLException(OptionError,"NoImagesDefined",
2948 (const char *) tag);
2951 if (attributes != (const xmlChar **) NULL)
2952 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2954 keyword=(const char *) attributes[i++];
2955 attribute=InterpretImageProperties(msl_info->image_info[n],
2956 msl_info->attributes[n],(const char *) attributes[i]);
2957 CloneString(&value,attribute);
2958 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2960 flop_image=FlopImage(msl_info->image[n],
2961 &msl_info->image[n]->exception);
2962 if (flop_image == (Image *) NULL)
2964 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2965 msl_info->image[n]=flop_image;
2968 if (LocaleCompare((const char *) tag,"frame") == 0)
2979 if (msl_info->image[n] == (Image *) NULL)
2981 ThrowMSLException(OptionError,"NoImagesDefined",
2982 (const char *) tag);
2985 SetGeometry(msl_info->image[n],&geometry);
2986 if (attributes != (const xmlChar **) NULL)
2987 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2989 keyword=(const char *) attributes[i++];
2990 attribute=InterpretImageProperties(msl_info->image_info[n],
2991 msl_info->attributes[n],(const char *) attributes[i]);
2992 CloneString(&value,attribute);
2998 if (LocaleCompare(keyword,"compose") == 0)
3000 option=ParseMagickOption(MagickComposeOptions,
3003 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3005 msl_info->image[n]->compose=(CompositeOperator) option;
3008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3015 if (LocaleCompare(keyword, "fill") == 0)
3017 (void) QueryColorDatabase(value,
3018 &msl_info->image[n]->matte_color,&exception);
3021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3028 if (LocaleCompare(keyword,"geometry") == 0)
3030 flags=ParsePageGeometry(msl_info->image[n],value,
3031 &geometry,&exception);
3032 if ((flags & HeightValue) == 0)
3033 geometry.height=geometry.width;
3034 frame_info.width=geometry.width;
3035 frame_info.height=geometry.height;
3036 frame_info.outer_bevel=geometry.x;
3037 frame_info.inner_bevel=geometry.y;
3040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3047 if (LocaleCompare(keyword,"height") == 0)
3049 frame_info.height=StringToLong(value);
3052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3059 if (LocaleCompare(keyword,"inner") == 0)
3061 frame_info.inner_bevel=StringToLong(value);
3064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3071 if (LocaleCompare(keyword,"outer") == 0)
3073 frame_info.outer_bevel=StringToLong(value);
3076 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3083 if (LocaleCompare(keyword,"width") == 0)
3085 frame_info.width=StringToLong(value);
3088 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3094 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3100 frame_info.x=(long) frame_info.width;
3101 frame_info.y=(long) frame_info.height;
3102 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3103 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3104 frame_image=FrameImage(msl_info->image[n],&frame_info,
3105 &msl_info->image[n]->exception);
3106 if (frame_image == (Image *) NULL)
3108 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3109 msl_info->image[n]=frame_image;
3112 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3117 if (LocaleCompare((const char *) tag,"gamma") == 0)
3120 gamma[MaxTextExtent];
3128 if (msl_info->image[n] == (Image *) NULL)
3130 ThrowMSLException(OptionError,"NoImagesDefined",
3131 (const char *) tag);
3134 channel=UndefinedChannel;
3139 if (attributes != (const xmlChar **) NULL)
3140 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3142 keyword=(const char *) attributes[i++];
3143 attribute=InterpretImageProperties(msl_info->image_info[n],
3144 msl_info->attributes[n],(const char *) attributes[i]);
3145 CloneString(&value,attribute);
3151 if (LocaleCompare(keyword,"blue") == 0)
3153 pixel.blue=StringToDouble(value);
3156 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3163 if (LocaleCompare(keyword,"channel") == 0)
3165 option=ParseChannelOption(value);
3167 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3169 channel=(ChannelType) option;
3172 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3179 if (LocaleCompare(keyword,"gamma") == 0)
3181 (void) CopyMagickString(gamma,value,MaxTextExtent);
3184 if (LocaleCompare(keyword,"green") == 0)
3186 pixel.green=StringToDouble(value);
3189 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3196 if (LocaleCompare(keyword,"red") == 0)
3198 pixel.red=StringToDouble(value);
3201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3214 (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
3215 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3220 (void) GammaImage(msl_info->image[n],gamma);
3225 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3230 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3236 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3243 else if (LocaleCompare((const char *) tag,"get") == 0)
3245 if (msl_info->image[n] == (Image *) NULL)
3247 ThrowMSLException(OptionError,"NoImagesDefined",
3248 (const char *) tag);
3251 if (attributes == (const xmlChar **) NULL)
3253 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3255 keyword=(const char *) attributes[i++];
3256 CloneString(&value,(const char *) attributes[i]);
3257 (void) CopyMagickString(key,value,MaxTextExtent);
3263 if (LocaleCompare(keyword,"height") == 0)
3265 (void) FormatMagickString(value,MaxTextExtent,"%ld",
3266 msl_info->image[n]->rows);
3267 (void) SetImageProperty(msl_info->attributes[n],key,value);
3270 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3275 if (LocaleCompare(keyword,"width") == 0)
3277 (void) FormatMagickString(value,MaxTextExtent,"%ld",
3278 msl_info->image[n]->columns);
3279 (void) SetImageProperty(msl_info->attributes[n],key,value);
3282 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3286 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3293 else if (LocaleCompare((const char *) tag, "group") == 0)
3295 msl_info->number_groups++;
3296 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3297 msl_info->group_info,msl_info->number_groups+1UL,
3298 sizeof(*msl_info->group_info));
3301 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3306 if (LocaleCompare((const char *) tag,"image") == 0)
3308 MSLPushImage(msl_info,(Image *) NULL);
3309 if (attributes == (const xmlChar **) NULL)
3311 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3313 keyword=(const char *) attributes[i++];
3314 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3315 msl_info->attributes[n],(const char *) attributes[i]));
3321 if (LocaleCompare(keyword,"color") == 0)
3326 (void) CopyMagickString(msl_info->image_info[n]->filename,
3327 "xc:",MaxTextExtent);
3328 (void) ConcatenateMagickString(msl_info->image_info[n]->
3329 filename,value,MaxTextExtent);
3330 next_image=ReadImage(msl_info->image_info[n],&exception);
3331 CatchException(&exception);
3332 if (next_image == (Image *) NULL)
3334 if (msl_info->image[n] == (Image *) NULL)
3335 msl_info->image[n]=next_image;
3342 Link image into image list.
3344 p=msl_info->image[n];
3345 while (p->next != (Image *) NULL)
3346 p=GetNextImageInList(p);
3347 next_image->previous=p;
3352 (void) SetMSLAttributes(msl_info,keyword,value);
3357 (void) SetMSLAttributes(msl_info,keyword,value);
3364 if (LocaleCompare((const char *) tag,"implode") == 0)
3372 if (msl_info->image[n] == (Image *) NULL)
3374 ThrowMSLException(OptionError,"NoImagesDefined",
3375 (const char *) tag);
3378 if (attributes != (const xmlChar **) NULL)
3379 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3381 keyword=(const char *) attributes[i++];
3382 attribute=InterpretImageProperties(msl_info->image_info[n],
3383 msl_info->attributes[n],(const char *) attributes[i]);
3384 CloneString(&value,attribute);
3390 if (LocaleCompare(keyword,"amount") == 0)
3392 geometry_info.rho=StringToDouble(value);
3395 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3402 if (LocaleCompare(keyword,"geometry") == 0)
3404 flags=ParseGeometry(value,&geometry_info);
3405 if ((flags & SigmaValue) == 0)
3406 geometry_info.sigma=1.0;
3409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3415 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3421 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3422 &msl_info->image[n]->exception);
3423 if (implode_image == (Image *) NULL)
3425 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3426 msl_info->image[n]=implode_image;
3429 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3434 if (LocaleCompare((const char *) tag,"label") == 0)
3436 if (LocaleCompare((const char *) tag, "level") == 0)
3439 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3441 if (msl_info->image[n] == (Image *) NULL)
3443 ThrowMSLException(OptionError,"NoImagesDefined",
3444 (const char *) tag);
3447 if (attributes == (const xmlChar **) NULL)
3449 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3451 keyword=(const char *) attributes[i++];
3452 CloneString(&value,(const char *) attributes[i]);
3453 (void) CopyMagickString(key,value,MaxTextExtent);
3459 if (LocaleCompare(keyword,"black") == 0)
3461 levelBlack = StringToDouble( value );
3464 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3470 if (LocaleCompare(keyword,"gamma") == 0)
3472 levelGamma = StringToDouble( value );
3475 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3481 if (LocaleCompare(keyword,"white") == 0)
3483 levelWhite = StringToDouble( value );
3486 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3491 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3499 char level[MaxTextExtent + 1];
3500 (void) FormatMagickString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3501 levelBlack,levelGamma,levelWhite);
3502 LevelImage ( msl_info->image[n], level );
3510 if (LocaleCompare((const char *) tag,"magnify") == 0)
3518 if (msl_info->image[n] == (Image *) NULL)
3520 ThrowMSLException(OptionError,"NoImagesDefined",
3521 (const char *) tag);
3524 if (attributes != (const xmlChar **) NULL)
3525 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3527 keyword=(const char *) attributes[i++];
3528 attribute=InterpretImageProperties(msl_info->image_info[n],
3529 msl_info->attributes[n],(const char *) attributes[i]);
3530 CloneString(&value,attribute);
3531 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3533 magnify_image=MagnifyImage(msl_info->image[n],
3534 &msl_info->image[n]->exception);
3535 if (magnify_image == (Image *) NULL)
3537 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3538 msl_info->image[n]=magnify_image;
3541 if (LocaleCompare((const char *) tag,"map") == 0)
3555 if (msl_info->image[n] == (Image *) NULL)
3557 ThrowMSLException(OptionError,"NoImagesDefined",
3558 (const char *) tag);
3561 affinity_image=NewImageList();
3563 if (attributes != (const xmlChar **) NULL)
3564 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3566 keyword=(const char *) attributes[i++];
3567 attribute=InterpretImageProperties(msl_info->image_info[n],
3568 msl_info->attributes[n],(const char *) attributes[i]);
3569 CloneString(&value,attribute);
3575 if (LocaleCompare(keyword,"dither") == 0)
3577 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
3580 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3582 dither=(MagickBooleanType) option;
3585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3592 if (LocaleCompare(keyword,"image") == 0)
3593 for (j=0; j < msl_info->n; j++)
3598 attribute=GetImageProperty(msl_info->attributes[j],"id");
3599 if ((attribute != (const char *) NULL) &&
3600 (LocaleCompare(attribute,value) == 0))
3602 affinity_image=CloneImage(msl_info->image[j],0,0,
3603 MagickFalse,&exception);
3611 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3617 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3618 quantize_info->dither=dither;
3619 (void) RemapImages(quantize_info,msl_info->image[n],
3621 quantize_info=DestroyQuantizeInfo(quantize_info);
3622 affinity_image=DestroyImage(affinity_image);
3625 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3637 Matte floodfill image.
3640 if (msl_info->image[n] == (Image *) NULL)
3642 ThrowMSLException(OptionError,"NoImagesDefined",
3643 (const char *) tag);
3646 SetGeometry(msl_info->image[n],&geometry);
3647 paint_method=FloodfillMethod;
3648 if (attributes != (const xmlChar **) NULL)
3649 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3651 keyword=(const char *) attributes[i++];
3652 attribute=InterpretImageProperties(msl_info->image_info[n],
3653 msl_info->attributes[n],(const char *) attributes[i]);
3654 CloneString(&value,attribute);
3660 if (LocaleCompare(keyword,"bordercolor") == 0)
3662 (void) QueryMagickColor(value,&target,&exception);
3663 paint_method=FillToBorderMethod;
3666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3673 if (LocaleCompare(keyword,"fuzz") == 0)
3675 msl_info->image[n]->fuzz=StringToDouble(value);
3678 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3685 if (LocaleCompare(keyword,"geometry") == 0)
3687 flags=ParsePageGeometry(msl_info->image[n],value,
3688 &geometry,&exception);
3689 if ((flags & HeightValue) == 0)
3690 geometry.height=geometry.width;
3691 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3692 geometry.x,geometry.y,&target,&exception);
3695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3702 if (LocaleCompare(keyword,"opacity") == 0)
3704 opacity=StringToDouble(value);
3707 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3714 if (LocaleCompare(keyword,"x") == 0)
3716 geometry.x=StringToLong(value);
3717 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3718 geometry.x,geometry.y,&target,&exception);
3721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3728 if (LocaleCompare(keyword,"y") == 0)
3730 geometry.y=StringToLong(value);
3731 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3732 geometry.x,geometry.y,&target,&exception);
3735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3747 draw_info=CloneDrawInfo(msl_info->image_info[n],
3748 msl_info->draw_info[n]);
3749 draw_info->fill.opacity=ClampToQuantum(opacity);
3750 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3751 draw_info,&target,geometry.x,geometry.y,
3752 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3753 draw_info=DestroyDrawInfo(draw_info);
3756 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3762 Median-filter image.
3764 if (msl_info->image[n] == (Image *) NULL)
3766 ThrowMSLException(OptionError,"NoImagesDefined",
3767 (const char *) tag);
3770 if (attributes != (const xmlChar **) NULL)
3771 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3773 keyword=(const char *) attributes[i++];
3774 attribute=InterpretImageProperties(msl_info->image_info[n],
3775 msl_info->attributes[n],(const char *) attributes[i]);
3776 CloneString(&value,attribute);
3782 if (LocaleCompare(keyword,"geometry") == 0)
3784 flags=ParseGeometry(value,&geometry_info);
3785 if ((flags & SigmaValue) == 0)
3786 geometry_info.sigma=1.0;
3789 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3796 if (LocaleCompare(keyword,"radius") == 0)
3798 geometry_info.rho=StringToDouble(value);
3801 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3807 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3813 median_image=MedianFilterImage(msl_info->image[n],geometry_info.rho,
3814 &msl_info->image[n]->exception);
3815 if (median_image == (Image *) NULL)
3817 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3818 msl_info->image[n]=median_image;
3821 if (LocaleCompare((const char *) tag,"minify") == 0)
3829 if (msl_info->image[n] == (Image *) NULL)
3831 ThrowMSLException(OptionError,"NoImagesDefined",
3832 (const char *) tag);
3835 if (attributes != (const xmlChar **) NULL)
3836 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3838 keyword=(const char *) attributes[i++];
3839 attribute=InterpretImageProperties(msl_info->image_info[n],
3840 msl_info->attributes[n],(const char *) attributes[i]);
3841 CloneString(&value,attribute);
3842 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3844 minify_image=MinifyImage(msl_info->image[n],
3845 &msl_info->image[n]->exception);
3846 if (minify_image == (Image *) NULL)
3848 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3849 msl_info->image[n]=minify_image;
3852 if (LocaleCompare((const char *) tag,"msl") == 0 )
3854 if (LocaleCompare((const char *) tag,"modulate") == 0)
3857 modulate[MaxTextExtent];
3862 if (msl_info->image[n] == (Image *) NULL)
3864 ThrowMSLException(OptionError,"NoImagesDefined",
3865 (const char *) tag);
3868 geometry_info.rho=100.0;
3869 geometry_info.sigma=100.0;
3870 geometry_info.xi=100.0;
3871 if (attributes != (const xmlChar **) NULL)
3872 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3874 keyword=(const char *) attributes[i++];
3875 attribute=InterpretImageProperties(msl_info->image_info[n],
3876 msl_info->attributes[n],(const char *) attributes[i]);
3877 CloneString(&value,attribute);
3883 if (LocaleCompare(keyword,"blackness") == 0)
3885 geometry_info.rho=StringToDouble(value);
3888 if (LocaleCompare(keyword,"brightness") == 0)
3890 geometry_info.rho=StringToDouble(value);
3893 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3900 if (LocaleCompare(keyword,"factor") == 0)
3902 flags=ParseGeometry(value,&geometry_info);
3905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3912 if (LocaleCompare(keyword,"hue") == 0)
3914 geometry_info.xi=StringToDouble(value);
3917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3924 if (LocaleCompare(keyword,"lightness") == 0)
3926 geometry_info.rho=StringToDouble(value);
3929 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3936 if (LocaleCompare(keyword,"saturation") == 0)
3938 geometry_info.sigma=StringToDouble(value);
3941 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3948 if (LocaleCompare(keyword,"whiteness") == 0)
3950 geometry_info.sigma=StringToDouble(value);
3953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 (void) FormatMagickString(modulate,MaxTextExtent,"%g,%g,%g",
3966 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3967 (void) ModulateImage(msl_info->image[n],modulate);
3970 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3975 if (LocaleCompare((const char *) tag,"negate") == 0)
3983 if (msl_info->image[n] == (Image *) NULL)
3985 ThrowMSLException(OptionError,"NoImagesDefined",
3986 (const char *) tag);
3990 if (attributes != (const xmlChar **) NULL)
3991 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3993 keyword=(const char *) attributes[i++];
3994 attribute=InterpretImageProperties(msl_info->image_info[n],
3995 msl_info->attributes[n],(const char *) attributes[i]);
3996 CloneString(&value,attribute);
4002 if (LocaleCompare(keyword,"channel") == 0)
4004 option=ParseChannelOption(value);
4006 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4008 channel=(ChannelType) option;
4011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4018 if (LocaleCompare(keyword,"gray") == 0)
4020 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4023 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4025 gray=(MagickBooleanType) option;
4028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4040 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4043 if (LocaleCompare((const char *) tag,"normalize") == 0)
4048 if (msl_info->image[n] == (Image *) NULL)
4050 ThrowMSLException(OptionError,"NoImagesDefined",
4051 (const char *) tag);
4054 if (attributes != (const xmlChar **) NULL)
4055 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4057 keyword=(const char *) attributes[i++];
4058 attribute=InterpretImageProperties(msl_info->image_info[n],
4059 msl_info->attributes[n],(const char *) attributes[i]);
4060 CloneString(&value,attribute);
4066 if (LocaleCompare(keyword,"channel") == 0)
4068 option=ParseChannelOption(value);
4070 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4072 channel=(ChannelType) option;
4075 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4087 (void) NormalizeImageChannel(msl_info->image[n],channel);
4090 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4095 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4103 if (msl_info->image[n] == (Image *) NULL)
4105 ThrowMSLException(OptionError,"NoImagesDefined",
4106 (const char *) tag);
4109 if (attributes != (const xmlChar **) NULL)
4110 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4112 keyword=(const char *) attributes[i++];
4113 attribute=InterpretImageProperties(msl_info->image_info[n],
4114 msl_info->attributes[n],(const char *) attributes[i]);
4115 CloneString(&value,attribute);
4121 if (LocaleCompare(keyword,"geometry") == 0)
4123 flags=ParseGeometry(value,&geometry_info);
4124 if ((flags & SigmaValue) == 0)
4125 geometry_info.sigma=1.0;
4128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(keyword,"radius") == 0)
4137 geometry_info.rho=StringToDouble(value);
4140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4153 &msl_info->image[n]->exception);
4154 if (paint_image == (Image *) NULL)
4156 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4157 msl_info->image[n]=paint_image;
4160 if (LocaleCompare((const char *) tag,"opaque") == 0)
4169 if (msl_info->image[n] == (Image *) NULL)
4171 ThrowMSLException(OptionError,"NoImagesDefined",
4172 (const char *) tag);
4175 (void) QueryMagickColor("none",&target,&exception);
4176 (void) QueryMagickColor("none",&fill_color,&exception);
4177 if (attributes != (const xmlChar **) NULL)
4178 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4180 keyword=(const char *) attributes[i++];
4181 attribute=InterpretImageProperties(msl_info->image_info[n],
4182 msl_info->attributes[n],(const char *) attributes[i]);
4183 CloneString(&value,attribute);
4189 if (LocaleCompare(keyword,"channel") == 0)
4191 option=ParseChannelOption(value);
4193 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4195 channel=(ChannelType) option;
4198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4205 if (LocaleCompare(keyword,"fill") == 0)
4207 (void) QueryMagickColor(value,&fill_color,&exception);
4210 if (LocaleCompare(keyword,"fuzz") == 0)
4212 msl_info->image[n]->fuzz=StringToDouble(value);
4215 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4227 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4228 &target,&fill_color,MagickFalse);
4231 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4236 if (LocaleCompare((const char *) tag,"print") == 0)
4238 if (attributes == (const xmlChar **) NULL)
4240 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4242 keyword=(const char *) attributes[i++];
4243 attribute=InterpretImageProperties(msl_info->image_info[n],
4244 msl_info->attributes[n],(const char *) attributes[i]);
4245 CloneString(&value,attribute);
4251 if (LocaleCompare(keyword,"output") == 0)
4253 (void) fprintf(stdout,"%s",value);
4256 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4261 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4268 if (LocaleCompare((const char *) tag, "profile") == 0)
4270 if (msl_info->image[n] == (Image *) NULL)
4272 ThrowMSLException(OptionError,"NoImagesDefined",
4273 (const char *) tag);
4276 if (attributes == (const xmlChar **) NULL)
4278 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4292 keyword=(const char *) attributes[i++];
4293 attribute=InterpretImageProperties(msl_info->image_info[n],
4294 msl_info->attributes[n],(const char *) attributes[i]);
4295 CloneString(&value,attribute);
4296 if (*keyword == '+')
4299 Remove a profile from the image.
4301 (void) ProfileImage(msl_info->image[n],keyword,
4302 (const unsigned char *) NULL,0,MagickTrue);
4306 Associate a profile with the image.
4308 profile_info=CloneImageInfo(msl_info->image_info[n]);
4309 profile=GetImageProfile(msl_info->image[n],"iptc");
4310 if (profile != (StringInfo *) NULL)
4311 profile_info->profile=(void *) CloneStringInfo(profile);
4312 profile_image=GetImageCache(profile_info,keyword,&exception);
4313 profile_info=DestroyImageInfo(profile_info);
4314 if (profile_image == (Image *) NULL)
4317 name[MaxTextExtent],
4318 filename[MaxTextExtent];
4326 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4327 (void) CopyMagickString(name,keyword,MaxTextExtent);
4328 for (p=filename; *p != '\0'; p++)
4329 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4330 (IsPathAccessible(keyword) == MagickFalse))
4336 Look for profile name (e.g. name:profile).
4338 (void) CopyMagickString(name,filename,(size_t)
4340 for (q=filename; *q != '\0'; q++)
4344 profile=FileToStringInfo(filename,~0UL,&exception);
4345 if (profile != (StringInfo *) NULL)
4347 (void) ProfileImage(msl_info->image[n],name,
4348 GetStringInfoDatum(profile),(unsigned long)
4349 GetStringInfoLength(profile),MagickFalse);
4350 profile=DestroyStringInfo(profile);
4354 ResetImageProfileIterator(profile_image);
4355 name=GetNextImageProfile(profile_image);
4356 while (name != (const char *) NULL)
4358 profile=GetImageProfile(profile_image,name);
4359 if (profile != (StringInfo *) NULL)
4360 (void) ProfileImage(msl_info->image[n],name,
4361 GetStringInfoDatum(profile),(unsigned long)
4362 GetStringInfoLength(profile),MagickFalse);
4363 name=GetNextImageProfile(profile_image);
4365 profile_image=DestroyImage(profile_image);
4369 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4374 if (LocaleCompare((const char *) tag,"quantize") == 0)
4382 if (msl_info->image[n] == (Image *) NULL)
4384 ThrowMSLException(OptionError,"NoImagesDefined",
4385 (const char *) tag);
4388 GetQuantizeInfo(&quantize_info);
4389 if (attributes != (const xmlChar **) NULL)
4390 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4392 keyword=(const char *) attributes[i++];
4393 attribute=InterpretImageProperties(msl_info->image_info[n],
4394 msl_info->attributes[n],(const char *) attributes[i]);
4395 CloneString(&value,attribute);
4401 if (LocaleCompare(keyword,"colors") == 0)
4403 quantize_info.number_colors=StringToLong(value);
4406 if (LocaleCompare(keyword,"colorspace") == 0)
4408 option=ParseMagickOption(MagickColorspaceOptions,
4411 ThrowMSLException(OptionError,
4412 "UnrecognizedColorspaceType",value);
4413 quantize_info.colorspace=(ColorspaceType) option;
4416 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4423 if (LocaleCompare(keyword,"dither") == 0)
4425 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4428 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4430 quantize_info.dither=(MagickBooleanType) option;
4433 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4440 if (LocaleCompare(keyword,"measure") == 0)
4442 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4445 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4447 quantize_info.measure_error=(MagickBooleanType) option;
4450 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4457 if (LocaleCompare(keyword,"treedepth") == 0)
4459 quantize_info.tree_depth=StringToLong(value);
4462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4474 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4477 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4480 text[MaxTextExtent];
4491 draw_info=CloneDrawInfo(msl_info->image_info[n],
4492 msl_info->draw_info[n]);
4494 current=draw_info->affine;
4495 GetAffineMatrix(&affine);
4496 if (attributes != (const xmlChar **) NULL)
4497 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4499 keyword=(const char *) attributes[i++];
4500 attribute=InterpretImageProperties(msl_info->image_info[n],
4501 msl_info->attributes[n],(const char *) attributes[i]);
4502 CloneString(&value,attribute);
4508 if (LocaleCompare(keyword,"affine") == 0)
4514 draw_info->affine.sx=strtod(p,&p);
4517 draw_info->affine.rx=strtod(p,&p);
4520 draw_info->affine.ry=strtod(p,&p);
4523 draw_info->affine.sy=strtod(p,&p);
4526 draw_info->affine.tx=strtod(p,&p);
4529 draw_info->affine.ty=strtod(p,&p);
4532 if (LocaleCompare(keyword,"align") == 0)
4534 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
4537 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4539 draw_info->align=(AlignType) option;
4542 if (LocaleCompare(keyword,"antialias") == 0)
4544 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4547 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4549 draw_info->stroke_antialias=(MagickBooleanType) option;
4550 draw_info->text_antialias=(MagickBooleanType) option;
4553 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4560 if (LocaleCompare(keyword,"density") == 0)
4562 CloneString(&draw_info->density,value);
4565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4572 if (LocaleCompare(keyword,"encoding") == 0)
4574 CloneString(&draw_info->encoding,value);
4577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4584 if (LocaleCompare(keyword, "fill") == 0)
4586 (void) QueryColorDatabase(value,&draw_info->fill,
4590 if (LocaleCompare(keyword,"family") == 0)
4592 CloneString(&draw_info->family,value);
4595 if (LocaleCompare(keyword,"font") == 0)
4597 CloneString(&draw_info->font,value);
4600 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4607 if (LocaleCompare(keyword,"geometry") == 0)
4609 flags=ParsePageGeometry(msl_info->image[n],value,
4610 &geometry,&exception);
4611 if ((flags & HeightValue) == 0)
4612 geometry.height=geometry.width;
4615 if (LocaleCompare(keyword,"gravity") == 0)
4617 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
4620 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4622 draw_info->gravity=(GravityType) option;
4625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4632 if (LocaleCompare(keyword,"pointsize") == 0)
4634 draw_info->pointsize=StringToDouble(value);
4637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4644 if (LocaleCompare(keyword,"rotate") == 0)
4646 angle=StringToDouble(value);
4647 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4648 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4649 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4650 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4660 if (LocaleCompare(keyword,"scale") == 0)
4662 flags=ParseGeometry(value,&geometry_info);
4663 if ((flags & SigmaValue) == 0)
4664 geometry_info.sigma=1.0;
4665 affine.sx=geometry_info.rho;
4666 affine.sy=geometry_info.sigma;
4669 if (LocaleCompare(keyword,"skewX") == 0)
4671 angle=StringToDouble(value);
4672 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4675 if (LocaleCompare(keyword,"skewY") == 0)
4677 angle=StringToDouble(value);
4678 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4681 if (LocaleCompare(keyword,"stretch") == 0)
4683 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
4686 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4688 draw_info->stretch=(StretchType) option;
4691 if (LocaleCompare(keyword, "stroke") == 0)
4693 (void) QueryColorDatabase(value,&draw_info->stroke,
4697 if (LocaleCompare(keyword,"strokewidth") == 0)
4699 draw_info->stroke_width=StringToLong(value);
4702 if (LocaleCompare(keyword,"style") == 0)
4704 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
4707 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4709 draw_info->style=(StyleType) option;
4712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4719 if (LocaleCompare(keyword,"text") == 0)
4721 CloneString(&draw_info->text,value);
4724 if (LocaleCompare(keyword,"translate") == 0)
4726 flags=ParseGeometry(value,&geometry_info);
4727 if ((flags & SigmaValue) == 0)
4728 geometry_info.sigma=1.0;
4729 affine.tx=geometry_info.rho;
4730 affine.ty=geometry_info.sigma;
4733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4740 if (LocaleCompare(keyword, "undercolor") == 0)
4742 (void) QueryColorDatabase(value,&draw_info->undercolor,
4746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4753 if (LocaleCompare(keyword,"weight") == 0)
4755 draw_info->weight=StringToLong(value);
4758 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4765 if (LocaleCompare(keyword,"x") == 0)
4767 geometry.x=StringToLong(value);
4770 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4777 if (LocaleCompare(keyword,"y") == 0)
4779 geometry.y=StringToLong(value);
4782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4794 (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
4795 geometry.width,geometry.height,geometry.x,geometry.y);
4796 CloneString(&draw_info->geometry,text);
4797 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
4798 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
4799 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
4800 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
4801 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
4803 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
4805 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4806 if (status != MagickFalse)
4811 image=msl_info->attributes[n];
4812 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4813 "%g",metrics.pixels_per_em.x);
4814 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4815 "%g",metrics.pixels_per_em.y);
4816 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4818 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4820 FormatImageProperty(image,"msl:font-metrics.width","%g",
4822 FormatImageProperty(image,"msl:font-metrics.height","%g",
4824 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4825 metrics.max_advance);
4826 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4828 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4830 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4832 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4834 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4836 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4839 draw_info=DestroyDrawInfo(draw_info);
4842 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4847 if (LocaleCompare((const char *) tag,"raise") == 0)
4855 if (msl_info->image[n] == (Image *) NULL)
4857 ThrowMSLException(OptionError,"NoImagesDefined",
4858 (const char *) tag);
4862 SetGeometry(msl_info->image[n],&geometry);
4863 if (attributes != (const xmlChar **) NULL)
4864 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4866 keyword=(const char *) attributes[i++];
4867 attribute=InterpretImageProperties(msl_info->image_info[n],
4868 msl_info->attributes[n],(const char *) attributes[i]);
4869 CloneString(&value,attribute);
4875 if (LocaleCompare(keyword,"geometry") == 0)
4877 flags=ParsePageGeometry(msl_info->image[n],value,
4878 &geometry,&exception);
4879 if ((flags & HeightValue) == 0)
4880 geometry.height=geometry.width;
4883 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4890 if (LocaleCompare(keyword,"height") == 0)
4892 geometry.height=StringToLong(value);
4895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4902 if (LocaleCompare(keyword,"raise") == 0)
4904 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4907 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4909 raise=(MagickBooleanType) option;
4912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4919 if (LocaleCompare(keyword,"width") == 0)
4921 geometry.width=StringToLong(value);
4924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4936 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4939 if (LocaleCompare((const char *) tag,"read") == 0)
4941 if (attributes == (const xmlChar **) NULL)
4943 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4945 keyword=(const char *) attributes[i++];
4946 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4947 msl_info->attributes[n],(const char *) attributes[i]));
4953 if (LocaleCompare(keyword,"filename") == 0)
4958 (void) CopyMagickString(msl_info->image_info[n]->filename,
4959 value,MaxTextExtent);
4960 image=ReadImage(msl_info->image_info[n],&exception);
4961 CatchException(&exception);
4962 if (image == (Image *) NULL)
4964 AppendImageToList(&msl_info->image[n],image);
4967 (void) SetMSLAttributes(msl_info,keyword,value);
4972 (void) SetMSLAttributes(msl_info,keyword,value);
4979 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4987 if (msl_info->image[n] == (Image *) NULL)
4989 ThrowMSLException(OptionError,"NoImagesDefined",
4990 (const char *) tag);
4993 if (attributes != (const xmlChar **) NULL)
4994 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4996 keyword=(const char *) attributes[i++];
4997 attribute=InterpretImageProperties(msl_info->image_info[n],
4998 msl_info->attributes[n],(const char *) attributes[i]);
4999 CloneString(&value,attribute);
5005 if (LocaleCompare(keyword,"geometry") == 0)
5007 flags=ParseGeometry(value,&geometry_info);
5008 if ((flags & SigmaValue) == 0)
5009 geometry_info.sigma=1.0;
5012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5019 if (LocaleCompare(keyword,"radius") == 0)
5021 geometry_info.rho=StringToDouble(value);
5024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5036 paint_image=ReduceNoiseImage(msl_info->image[n],geometry_info.rho,
5037 &msl_info->image[n]->exception);
5038 if (paint_image == (Image *) NULL)
5040 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5041 msl_info->image[n]=paint_image;
5044 else if (LocaleCompare((const char *) tag,"repage") == 0)
5046 /* init the values */
5047 width=msl_info->image[n]->page.width;
5048 height=msl_info->image[n]->page.height;
5049 x=msl_info->image[n]->page.x;
5050 y=msl_info->image[n]->page.y;
5052 if (msl_info->image[n] == (Image *) NULL)
5054 ThrowMSLException(OptionError,"NoImagesDefined",
5055 (const char *) tag);
5058 if (attributes == (const xmlChar **) NULL)
5060 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5062 keyword=(const char *) attributes[i++];
5063 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5064 msl_info->attributes[n],(const char *) attributes[i]));
5070 if (LocaleCompare(keyword,"geometry") == 0)
5078 flags=ParseAbsoluteGeometry(value,&geometry);
5079 if ((flags & WidthValue) != 0)
5081 if ((flags & HeightValue) == 0)
5082 geometry.height=geometry.width;
5083 width=geometry.width;
5084 height=geometry.height;
5086 if ((flags & AspectValue) != 0)
5088 if ((flags & XValue) != 0)
5090 if ((flags & YValue) != 0)
5095 if ((flags & XValue) != 0)
5098 if ((width == 0) && (geometry.x > 0))
5099 width=msl_info->image[n]->columns+geometry.x;
5101 if ((flags & YValue) != 0)
5104 if ((height == 0) && (geometry.y > 0))
5105 height=msl_info->image[n]->rows+geometry.y;
5110 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5116 if (LocaleCompare(keyword,"height") == 0)
5118 height = StringToLong( value );
5121 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5127 if (LocaleCompare(keyword,"width") == 0)
5129 width = StringToLong( value );
5132 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5138 if (LocaleCompare(keyword,"x") == 0)
5140 x = StringToLong( value );
5143 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5149 if (LocaleCompare(keyword,"y") == 0)
5151 y = StringToLong( value );
5154 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5159 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5165 msl_info->image[n]->page.width=width;
5166 msl_info->image[n]->page.height=height;
5167 msl_info->image[n]->page.x=x;
5168 msl_info->image[n]->page.y=y;
5171 else if (LocaleCompare((const char *) tag,"resample") == 0)
5177 if (msl_info->image[n] == (Image *) NULL)
5179 ThrowMSLException(OptionError,"NoImagesDefined",
5180 (const char *) tag);
5183 if (attributes == (const xmlChar **) NULL)
5185 x_resolution=DefaultResolution;
5186 y_resolution=DefaultResolution;
5187 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5189 keyword=(const char *) attributes[i++];
5190 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5191 msl_info->attributes[n],(const char *) attributes[i]));
5196 if (LocaleCompare(keyword,"blur") == 0)
5198 msl_info->image[n]->blur=StringToDouble(value);
5201 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5207 if (LocaleCompare(keyword,"geometry") == 0)
5212 flags=ParseGeometry(value,&geometry_info);
5213 if ((flags & SigmaValue) == 0)
5214 geometry_info.sigma*=geometry_info.rho;
5215 x_resolution=geometry_info.rho;
5216 y_resolution=geometry_info.sigma;
5219 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5225 if (LocaleCompare(keyword,"x-resolution") == 0)
5227 x_resolution=StringToDouble(value);
5230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5236 if (LocaleCompare(keyword,"y-resolution") == 0)
5238 y_resolution=StringToDouble(value);
5241 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5246 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5262 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5264 width=(unsigned long) (x_resolution*msl_info->image[n]->columns/
5265 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5266 msl_info->image[n]->x_resolution))+0.5);
5267 height=(unsigned long) (y_resolution*msl_info->image[n]->rows/
5268 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5269 msl_info->image[n]->y_resolution))+0.5);
5270 resample_image=ResizeImage(msl_info->image[n],width,height,
5271 msl_info->image[n]->filter,msl_info->image[n]->blur,
5272 &msl_info->image[n]->exception);
5273 if (resample_image == (Image *) NULL)
5275 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5276 msl_info->image[n]=resample_image;
5280 if (LocaleCompare((const char *) tag,"resize") == 0)
5294 if (msl_info->image[n] == (Image *) NULL)
5296 ThrowMSLException(OptionError,"NoImagesDefined",
5297 (const char *) tag);
5300 filter=UndefinedFilter;
5302 if (attributes != (const xmlChar **) NULL)
5303 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5305 keyword=(const char *) attributes[i++];
5306 attribute=InterpretImageProperties(msl_info->image_info[n],
5307 msl_info->attributes[n],(const char *) attributes[i]);
5308 CloneString(&value,attribute);
5314 if (LocaleCompare(keyword,"filter") == 0)
5316 option=ParseMagickOption(MagickFilterOptions,MagickFalse,
5319 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5321 filter=(FilterTypes) option;
5324 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5331 if (LocaleCompare(keyword,"geometry") == 0)
5333 flags=ParseRegionGeometry(msl_info->image[n],value,
5334 &geometry,&exception);
5337 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5344 if (LocaleCompare(keyword,"height") == 0)
5346 geometry.height=StringToUnsignedLong(value);
5349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5356 if (LocaleCompare(keyword,"support") == 0)
5358 blur=StringToDouble(value);
5361 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5368 if (LocaleCompare(keyword,"width") == 0)
5370 geometry.width=StringToLong(value);
5373 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5379 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5385 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5386 geometry.height,filter,blur,&msl_info->image[n]->exception);
5387 if (resize_image == (Image *) NULL)
5389 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5390 msl_info->image[n]=resize_image;
5393 if (LocaleCompare((const char *) tag,"roll") == 0)
5401 if (msl_info->image[n] == (Image *) NULL)
5403 ThrowMSLException(OptionError,"NoImagesDefined",
5404 (const char *) tag);
5407 SetGeometry(msl_info->image[n],&geometry);
5408 if (attributes != (const xmlChar **) NULL)
5409 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5411 keyword=(const char *) attributes[i++];
5412 attribute=InterpretImageProperties(msl_info->image_info[n],
5413 msl_info->attributes[n],(const char *) attributes[i]);
5414 CloneString(&value,attribute);
5420 if (LocaleCompare(keyword,"geometry") == 0)
5422 flags=ParsePageGeometry(msl_info->image[n],value,
5423 &geometry,&exception);
5424 if ((flags & HeightValue) == 0)
5425 geometry.height=geometry.width;
5428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5435 if (LocaleCompare(keyword,"x") == 0)
5437 geometry.x=StringToLong(value);
5440 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5447 if (LocaleCompare(keyword,"y") == 0)
5449 geometry.y=StringToLong(value);
5452 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5458 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5464 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5465 &msl_info->image[n]->exception);
5466 if (roll_image == (Image *) NULL)
5468 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5469 msl_info->image[n]=roll_image;
5472 else if (LocaleCompare((const char *) tag,"roll") == 0)
5474 /* init the values */
5475 width=msl_info->image[n]->columns;
5476 height=msl_info->image[n]->rows;
5479 if (msl_info->image[n] == (Image *) NULL)
5481 ThrowMSLException(OptionError,"NoImagesDefined",
5482 (const char *) tag);
5485 if (attributes == (const xmlChar **) NULL)
5487 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5489 keyword=(const char *) attributes[i++];
5490 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5491 msl_info->attributes[n],(const char *) attributes[i]));
5497 if (LocaleCompare(keyword,"geometry") == 0)
5499 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5502 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5508 if (LocaleCompare(keyword,"x") == 0)
5510 x = StringToLong( value );
5513 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5519 if (LocaleCompare(keyword,"y") == 0)
5521 y = StringToLong( value );
5524 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5529 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5542 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5543 if (newImage == (Image *) NULL)
5545 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5546 msl_info->image[n]=newImage;
5551 if (LocaleCompare((const char *) tag,"rotate") == 0)
5559 if (msl_info->image[n] == (Image *) NULL)
5561 ThrowMSLException(OptionError,"NoImagesDefined",
5562 (const char *) tag);
5565 if (attributes != (const xmlChar **) NULL)
5566 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5568 keyword=(const char *) attributes[i++];
5569 attribute=InterpretImageProperties(msl_info->image_info[n],
5570 msl_info->attributes[n],(const char *) attributes[i]);
5571 CloneString(&value,attribute);
5577 if (LocaleCompare(keyword,"degrees") == 0)
5579 geometry_info.rho=StringToDouble(value);
5582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5589 if (LocaleCompare(keyword,"geometry") == 0)
5591 flags=ParseGeometry(value,&geometry_info);
5592 if ((flags & SigmaValue) == 0)
5593 geometry_info.sigma=1.0;
5596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5608 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5609 &msl_info->image[n]->exception);
5610 if (rotate_image == (Image *) NULL)
5612 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5613 msl_info->image[n]=rotate_image;
5616 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5618 /* init the values */
5621 if (msl_info->image[n] == (Image *) NULL)
5623 ThrowMSLException(OptionError,"NoImagesDefined",
5624 (const char *) tag);
5627 if (attributes == (const xmlChar **) NULL)
5629 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5631 keyword=(const char *) attributes[i++];
5632 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5633 msl_info->attributes[n],(const char *) attributes[i]));
5639 if (LocaleCompare(keyword,"degrees") == 0)
5641 degrees = StringToDouble( value );
5644 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5649 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5662 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5663 if (newImage == (Image *) NULL)
5665 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5666 msl_info->image[n]=newImage;
5671 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5676 if (LocaleCompare((const char *) tag,"sample") == 0)
5684 if (msl_info->image[n] == (Image *) NULL)
5686 ThrowMSLException(OptionError,"NoImagesDefined",
5687 (const char *) tag);
5690 if (attributes != (const xmlChar **) NULL)
5691 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5693 keyword=(const char *) attributes[i++];
5694 attribute=InterpretImageProperties(msl_info->image_info[n],
5695 msl_info->attributes[n],(const char *) attributes[i]);
5696 CloneString(&value,attribute);
5702 if (LocaleCompare(keyword,"geometry") == 0)
5704 flags=ParseRegionGeometry(msl_info->image[n],value,
5705 &geometry,&exception);
5708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5715 if (LocaleCompare(keyword,"height") == 0)
5717 geometry.height=StringToUnsignedLong(value);
5720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5727 if (LocaleCompare(keyword,"width") == 0)
5729 geometry.width=StringToLong(value);
5732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5744 sample_image=SampleImage(msl_info->image[n],geometry.width,
5745 geometry.height,&msl_info->image[n]->exception);
5746 if (sample_image == (Image *) NULL)
5748 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5749 msl_info->image[n]=sample_image;
5752 if (LocaleCompare((const char *) tag,"scale") == 0)
5760 if (msl_info->image[n] == (Image *) NULL)
5762 ThrowMSLException(OptionError,"NoImagesDefined",
5763 (const char *) tag);
5766 if (attributes != (const xmlChar **) NULL)
5767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5769 keyword=(const char *) attributes[i++];
5770 attribute=InterpretImageProperties(msl_info->image_info[n],
5771 msl_info->attributes[n],(const char *) attributes[i]);
5772 CloneString(&value,attribute);
5778 if (LocaleCompare(keyword,"geometry") == 0)
5780 flags=ParseRegionGeometry(msl_info->image[n],value,
5781 &geometry,&exception);
5784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5791 if (LocaleCompare(keyword,"height") == 0)
5793 geometry.height=StringToUnsignedLong(value);
5796 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5803 if (LocaleCompare(keyword,"width") == 0)
5805 geometry.width=StringToLong(value);
5808 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5814 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5820 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5821 geometry.height,&msl_info->image[n]->exception);
5822 if (scale_image == (Image *) NULL)
5824 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5825 msl_info->image[n]=scale_image;
5828 if (LocaleCompare((const char *) tag,"segment") == 0)
5839 if (msl_info->image[n] == (Image *) NULL)
5841 ThrowMSLException(OptionError,"NoImagesDefined",
5842 (const char *) tag);
5845 geometry_info.rho=1.0;
5846 geometry_info.sigma=1.5;
5847 colorspace=RGBColorspace;
5848 verbose=MagickFalse;
5849 if (attributes != (const xmlChar **) NULL)
5850 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5852 keyword=(const char *) attributes[i++];
5853 attribute=InterpretImageProperties(msl_info->image_info[n],
5854 msl_info->attributes[n],(const char *) attributes[i]);
5855 CloneString(&value,attribute);
5861 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5863 geometry_info.rho=StringToDouble(value);
5866 if (LocaleCompare(keyword,"colorspace") == 0)
5868 option=ParseMagickOption(MagickColorspaceOptions,
5871 ThrowMSLException(OptionError,
5872 "UnrecognizedColorspaceType",value);
5873 colorspace=(ColorspaceType) option;
5876 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5883 if (LocaleCompare(keyword,"geometry") == 0)
5885 flags=ParseGeometry(value,&geometry_info);
5886 if ((flags & SigmaValue) == 0)
5887 geometry_info.sigma=1.5;
5890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5897 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5899 geometry_info.sigma=StringToDouble(value);
5902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5914 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5915 geometry_info.rho,geometry_info.sigma);
5918 else if (LocaleCompare((const char *) tag, "set") == 0)
5920 if (msl_info->image[n] == (Image *) NULL)
5922 ThrowMSLException(OptionError,"NoImagesDefined",
5923 (const char *) tag);
5927 if (attributes == (const xmlChar **) NULL)
5929 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5931 keyword=(const char *) attributes[i++];
5932 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5933 msl_info->attributes[n],(const char *) attributes[i]));
5939 if (LocaleCompare(keyword,"clip-mask") == 0)
5941 for (j=0; j < msl_info->n; j++)
5946 property=GetImageProperty(msl_info->attributes[j],"id");
5947 if (LocaleCompare(property,value) == 0)
5949 SetImageMask(msl_info->image[n],msl_info->image[j]);
5955 if (LocaleCompare(keyword,"clip-path") == 0)
5957 for (j=0; j < msl_info->n; j++)
5962 property=GetImageProperty(msl_info->attributes[j],"id");
5963 if (LocaleCompare(property,value) == 0)
5965 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5971 if (LocaleCompare(keyword,"colorspace") == 0)
5976 colorspace=(ColorspaceType) ParseMagickOption(
5977 MagickColorspaceOptions,MagickFalse,keyword);
5979 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5981 (void) TransformImageColorspace(msl_info->image[n],
5982 (ColorspaceType) colorspace);
5985 (void) SetMSLAttributes(msl_info,keyword,value);
5991 if (LocaleCompare(keyword,"density") == 0)
5993 flags=ParseGeometry(value,&geometry_info);
5994 msl_info->image[n]->x_resolution=geometry_info.rho;
5995 msl_info->image[n]->y_resolution=geometry_info.sigma;
5996 if ((flags & SigmaValue) == 0)
5997 msl_info->image[n]->y_resolution=
5998 msl_info->image[n]->x_resolution;
6001 (void) SetMSLAttributes(msl_info,keyword,value);
6007 if (LocaleCompare(keyword, "opacity") == 0)
6009 long opac = OpaqueOpacity,
6010 len = (long) strlen( value );
6012 if (value[len-1] == '%') {
6014 (void) CopyMagickString(tmp,value,len);
6015 opac = StringToLong( tmp );
6016 opac = (int)(QuantumRange * ((float)opac/100));
6018 opac = StringToLong( value );
6019 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6022 (void) SetMSLAttributes(msl_info,keyword,value);
6028 if (LocaleCompare(keyword, "page") == 0)
6031 page[MaxTextExtent];
6042 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6043 image_option=GetImageOption(msl_info->image_info[n],"page");
6044 if (image_option != (const char *) NULL)
6045 flags=ParseAbsoluteGeometry(image_option,&geometry);
6046 flags=ParseAbsoluteGeometry(value,&geometry);
6047 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
6048 geometry.width,geometry.height);
6049 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6050 (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
6051 geometry.width,geometry.height,geometry.x,geometry.y);
6052 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6053 msl_info->image_info[n]->page=GetPageGeometry(page);
6056 (void) SetMSLAttributes(msl_info,keyword,value);
6061 (void) SetMSLAttributes(msl_info,keyword,value);
6068 if (LocaleCompare((const char *) tag,"shade") == 0)
6079 if (msl_info->image[n] == (Image *) NULL)
6081 ThrowMSLException(OptionError,"NoImagesDefined",
6082 (const char *) tag);
6086 if (attributes != (const xmlChar **) NULL)
6087 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6089 keyword=(const char *) attributes[i++];
6090 attribute=InterpretImageProperties(msl_info->image_info[n],
6091 msl_info->attributes[n],(const char *) attributes[i]);
6092 CloneString(&value,attribute);
6098 if (LocaleCompare(keyword,"azimuth") == 0)
6100 geometry_info.rho=StringToDouble(value);
6103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6110 if (LocaleCompare(keyword,"elevation") == 0)
6112 geometry_info.sigma=StringToDouble(value);
6115 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6122 if (LocaleCompare(keyword,"geometry") == 0)
6124 flags=ParseGeometry(value,&geometry_info);
6125 if ((flags & SigmaValue) == 0)
6126 geometry_info.sigma=1.0;
6129 if (LocaleCompare(keyword,"gray") == 0)
6131 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6134 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6136 gray=(MagickBooleanType) option;
6139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6145 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6151 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6152 geometry_info.sigma,&msl_info->image[n]->exception);
6153 if (shade_image == (Image *) NULL)
6155 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6156 msl_info->image[n]=shade_image;
6159 if (LocaleCompare((const char *) tag,"shadow") == 0)
6167 if (msl_info->image[n] == (Image *) NULL)
6169 ThrowMSLException(OptionError,"NoImagesDefined",
6170 (const char *) tag);
6173 if (attributes != (const xmlChar **) NULL)
6174 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6176 keyword=(const char *) attributes[i++];
6177 attribute=InterpretImageProperties(msl_info->image_info[n],
6178 msl_info->attributes[n],(const char *) attributes[i]);
6179 CloneString(&value,attribute);
6185 if (LocaleCompare(keyword,"geometry") == 0)
6187 flags=ParseGeometry(value,&geometry_info);
6188 if ((flags & SigmaValue) == 0)
6189 geometry_info.sigma=1.0;
6192 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6199 if (LocaleCompare(keyword,"opacity") == 0)
6201 geometry_info.rho=StringToLong(value);
6204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6211 if (LocaleCompare(keyword,"sigma") == 0)
6213 geometry_info.sigma=StringToLong(value);
6221 if (LocaleCompare(keyword,"x") == 0)
6223 geometry_info.xi=StringToDouble(value);
6226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6233 if (LocaleCompare(keyword,"y") == 0)
6235 geometry_info.psi=StringToLong(value);
6238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6250 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6251 geometry_info.sigma,(long) ceil(geometry_info.xi-0.5),(long)
6252 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6253 if (shadow_image == (Image *) NULL)
6255 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6256 msl_info->image[n]=shadow_image;
6259 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6261 double radius = 0.0,
6264 if (msl_info->image[n] == (Image *) NULL)
6266 ThrowMSLException(OptionError,"NoImagesDefined",
6267 (const char *) tag);
6271 NOTE: sharpen can have no attributes, since we use all the defaults!
6273 if (attributes != (const xmlChar **) NULL)
6275 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6277 keyword=(const char *) attributes[i++];
6278 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6279 msl_info->attributes[n],(const char *) attributes[i]));
6285 if (LocaleCompare(keyword, "radius") == 0)
6287 radius = StringToDouble( value );
6290 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6296 if (LocaleCompare(keyword,"sigma") == 0)
6298 sigma = StringToLong( value );
6301 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6306 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6320 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6321 if (newImage == (Image *) NULL)
6323 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6324 msl_info->image[n]=newImage;
6328 else if (LocaleCompare((const char *) tag,"shave") == 0)
6330 /* init the values */
6334 if (msl_info->image[n] == (Image *) NULL)
6336 ThrowMSLException(OptionError,"NoImagesDefined",
6337 (const char *) tag);
6340 if (attributes == (const xmlChar **) NULL)
6342 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6344 keyword=(const char *) attributes[i++];
6345 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6346 msl_info->attributes[n],(const char *) attributes[i]));
6352 if (LocaleCompare(keyword,"geometry") == 0)
6354 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6357 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6363 if (LocaleCompare(keyword,"height") == 0)
6365 height = StringToLong( value );
6368 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6374 if (LocaleCompare(keyword,"width") == 0)
6376 width = StringToLong( value );
6379 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6384 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6399 rectInfo.height = height;
6400 rectInfo.width = width;
6405 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6406 &msl_info->image[n]->exception);
6407 if (newImage == (Image *) NULL)
6409 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6410 msl_info->image[n]=newImage;
6415 if (LocaleCompare((const char *) tag,"shear") == 0)
6423 if (msl_info->image[n] == (Image *) NULL)
6425 ThrowMSLException(OptionError,"NoImagesDefined",
6426 (const char *) tag);
6429 if (attributes != (const xmlChar **) NULL)
6430 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6432 keyword=(const char *) attributes[i++];
6433 attribute=InterpretImageProperties(msl_info->image_info[n],
6434 msl_info->attributes[n],(const char *) attributes[i]);
6435 CloneString(&value,attribute);
6441 if (LocaleCompare(keyword, "fill") == 0)
6443 (void) QueryColorDatabase(value,
6444 &msl_info->image[n]->background_color,&exception);
6447 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6454 if (LocaleCompare(keyword,"geometry") == 0)
6456 flags=ParseGeometry(value,&geometry_info);
6457 if ((flags & SigmaValue) == 0)
6458 geometry_info.sigma=1.0;
6461 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6468 if (LocaleCompare(keyword,"x") == 0)
6470 geometry_info.rho=StringToDouble(value);
6473 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6480 if (LocaleCompare(keyword,"y") == 0)
6482 geometry_info.sigma=StringToLong(value);
6485 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6497 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6498 geometry_info.sigma,&msl_info->image[n]->exception);
6499 if (shear_image == (Image *) NULL)
6501 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6502 msl_info->image[n]=shear_image;
6505 if (LocaleCompare((const char *) tag,"signature") == 0)
6510 if (msl_info->image[n] == (Image *) NULL)
6512 ThrowMSLException(OptionError,"NoImagesDefined",
6513 (const char *) tag);
6516 if (attributes != (const xmlChar **) NULL)
6517 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6519 keyword=(const char *) attributes[i++];
6520 attribute=InterpretImageProperties(msl_info->image_info[n],
6521 msl_info->attributes[n],(const char *) attributes[i]);
6522 CloneString(&value,attribute);
6527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6533 (void) SignatureImage(msl_info->image[n]);
6536 if (LocaleCompare((const char *) tag,"solarize") == 0)
6541 if (msl_info->image[n] == (Image *) NULL)
6543 ThrowMSLException(OptionError,"NoImagesDefined",
6544 (const char *) tag);
6547 geometry_info.rho=QuantumRange/2.0;
6548 if (attributes != (const xmlChar **) NULL)
6549 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6551 keyword=(const char *) attributes[i++];
6552 attribute=InterpretImageProperties(msl_info->image_info[n],
6553 msl_info->attributes[n],(const char *) attributes[i]);
6554 CloneString(&value,attribute);
6560 if (LocaleCompare(keyword,"geometry") == 0)
6562 flags=ParseGeometry(value,&geometry_info);
6565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6572 if (LocaleCompare(keyword,"threshold") == 0)
6574 geometry_info.rho=StringToDouble(value);
6577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6589 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6592 if (LocaleCompare((const char *) tag,"spread") == 0)
6600 if (msl_info->image[n] == (Image *) NULL)
6602 ThrowMSLException(OptionError,"NoImagesDefined",
6603 (const char *) tag);
6606 if (attributes != (const xmlChar **) NULL)
6607 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6609 keyword=(const char *) attributes[i++];
6610 attribute=InterpretImageProperties(msl_info->image_info[n],
6611 msl_info->attributes[n],(const char *) attributes[i]);
6612 CloneString(&value,attribute);
6618 if (LocaleCompare(keyword,"geometry") == 0)
6620 flags=ParseGeometry(value,&geometry_info);
6621 if ((flags & SigmaValue) == 0)
6622 geometry_info.sigma=1.0;
6625 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6632 if (LocaleCompare(keyword,"radius") == 0)
6634 geometry_info.rho=StringToDouble(value);
6637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6649 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6650 &msl_info->image[n]->exception);
6651 if (spread_image == (Image *) NULL)
6653 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6654 msl_info->image[n]=spread_image;
6657 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6660 watermark = (Image*)NULL;
6662 if (msl_info->image[n] == (Image *) NULL)
6664 ThrowMSLException(OptionError,"NoImagesDefined",
6665 (const char *) tag);
6668 if (attributes == (const xmlChar **) NULL)
6670 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6672 keyword=(const char *) attributes[i++];
6673 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6674 msl_info->attributes[n],(const char *) attributes[i]));
6680 if (LocaleCompare(keyword,"image") == 0)
6682 for (j=0; j<msl_info->n;j++)
6685 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6686 if (theAttr && LocaleCompare(theAttr, value) == 0)
6688 watermark = msl_info->image[j];
6694 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6699 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6708 if ( watermark != (Image*) NULL )
6713 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6714 if (newImage == (Image *) NULL)
6716 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6717 msl_info->image[n]=newImage;
6720 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6722 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6725 stereoImage = (Image*)NULL;
6727 if (msl_info->image[n] == (Image *) NULL)
6729 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6732 if (attributes == (const xmlChar **) NULL)
6734 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6736 keyword=(const char *) attributes[i++];
6737 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6738 msl_info->attributes[n],(const char *) attributes[i]));
6744 if (LocaleCompare(keyword,"image") == 0)
6746 for (j=0; j<msl_info->n;j++)
6749 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6750 if (theAttr && LocaleCompare(theAttr, value) == 0)
6752 stereoImage = msl_info->image[j];
6758 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6763 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6772 if ( stereoImage != (Image*) NULL )
6777 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6778 if (newImage == (Image *) NULL)
6780 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6781 msl_info->image[n]=newImage;
6784 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6786 if (LocaleCompare((const char *) tag,"swap") == 0)
6797 if (msl_info->image[n] == (Image *) NULL)
6799 ThrowMSLException(OptionError,"NoImagesDefined",
6800 (const char *) tag);
6805 if (attributes != (const xmlChar **) NULL)
6806 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6808 keyword=(const char *) attributes[i++];
6809 attribute=InterpretImageProperties(msl_info->image_info[n],
6810 msl_info->attributes[n],(const char *) attributes[i]);
6811 CloneString(&value,attribute);
6817 if (LocaleCompare(keyword,"indexes") == 0)
6819 flags=ParseGeometry(value,&geometry_info);
6820 index=(long) geometry_info.rho;
6821 if ((flags & SigmaValue) == 0)
6822 swap_index=(long) geometry_info.sigma;
6825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6831 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6840 p=GetImageFromList(msl_info->image[n],index);
6841 q=GetImageFromList(msl_info->image[n],swap_index);
6842 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6844 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6847 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6848 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6849 ReplaceImageInList(&q,swap);
6850 msl_info->image[n]=GetFirstImageInList(q);
6853 if (LocaleCompare((const char *) tag,"swirl") == 0)
6861 if (msl_info->image[n] == (Image *) NULL)
6863 ThrowMSLException(OptionError,"NoImagesDefined",
6864 (const char *) tag);
6867 if (attributes != (const xmlChar **) NULL)
6868 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6870 keyword=(const char *) attributes[i++];
6871 attribute=InterpretImageProperties(msl_info->image_info[n],
6872 msl_info->attributes[n],(const char *) attributes[i]);
6873 CloneString(&value,attribute);
6879 if (LocaleCompare(keyword,"degrees") == 0)
6881 geometry_info.rho=StringToDouble(value);
6884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6891 if (LocaleCompare(keyword,"geometry") == 0)
6893 flags=ParseGeometry(value,&geometry_info);
6894 if ((flags & SigmaValue) == 0)
6895 geometry_info.sigma=1.0;
6898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6910 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6911 &msl_info->image[n]->exception);
6912 if (swirl_image == (Image *) NULL)
6914 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6915 msl_info->image[n]=swirl_image;
6918 if (LocaleCompare((const char *) tag,"sync") == 0)
6923 if (msl_info->image[n] == (Image *) NULL)
6925 ThrowMSLException(OptionError,"NoImagesDefined",
6926 (const char *) tag);
6929 if (attributes != (const xmlChar **) NULL)
6930 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6932 keyword=(const char *) attributes[i++];
6933 attribute=InterpretImageProperties(msl_info->image_info[n],
6934 msl_info->attributes[n],(const char *) attributes[i]);
6935 CloneString(&value,attribute);
6940 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6946 (void) SyncImage(msl_info->image[n]);
6949 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6954 if (LocaleCompare((const char *) tag,"map") == 0)
6962 if (msl_info->image[n] == (Image *) NULL)
6964 ThrowMSLException(OptionError,"NoImagesDefined",
6965 (const char *) tag);
6968 texture_image=NewImageList();
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);
6981 if (LocaleCompare(keyword,"image") == 0)
6982 for (j=0; j < msl_info->n; j++)
6987 attribute=GetImageProperty(msl_info->attributes[j],"id");
6988 if ((attribute != (const char *) NULL) &&
6989 (LocaleCompare(attribute,value) == 0))
6991 texture_image=CloneImage(msl_info->image[j],0,0,
6992 MagickFalse,&exception);
7000 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7006 (void) TextureImage(msl_info->image[n],texture_image);
7007 texture_image=DestroyImage(texture_image);
7010 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7012 /* init the values */
7013 double threshold = 0;
7015 if (msl_info->image[n] == (Image *) NULL)
7017 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7020 if (attributes == (const xmlChar **) NULL)
7022 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7024 keyword=(const char *) attributes[i++];
7025 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7026 msl_info->attributes[n],(const char *) attributes[i]));
7032 if (LocaleCompare(keyword,"threshold") == 0)
7034 threshold = StringToDouble( value );
7037 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7042 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7052 BilevelImageChannel(msl_info->image[n],
7053 (ChannelType) ((long) (AllChannels &~ (long) OpacityChannel)),
7058 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7060 if (msl_info->image[n] == (Image *) NULL)
7062 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7065 if (attributes == (const xmlChar **) NULL)
7067 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7069 keyword=(const char *) attributes[i++];
7070 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7071 msl_info->attributes[n],(const char *) attributes[i]));
7077 if (LocaleCompare(keyword,"color") == 0)
7082 (void) QueryMagickColor(value,&target,&exception);
7083 (void) TransparentPaintImage(msl_info->image[n],&target,
7084 TransparentOpacity,MagickFalse);
7087 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7092 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7099 else if (LocaleCompare((const char *) tag, "trim") == 0)
7101 if (msl_info->image[n] == (Image *) NULL)
7103 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7107 /* no attributes here */
7109 /* process the image */
7116 /* all zeros on a crop == trim edges! */
7117 rectInfo.height = rectInfo.width = 0;
7118 rectInfo.x = rectInfo.y = 0;
7120 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7121 if (newImage == (Image *) NULL)
7123 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7124 msl_info->image[n]=newImage;
7128 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7133 if (LocaleCompare((const char *) tag,"write") == 0)
7135 if (msl_info->image[n] == (Image *) NULL)
7137 ThrowMSLException(OptionError,"NoImagesDefined",
7138 (const char *) tag);
7141 if (attributes == (const xmlChar **) NULL)
7143 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7145 keyword=(const char *) attributes[i++];
7146 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7147 msl_info->attributes[n],(const char *) attributes[i]));
7153 if (LocaleCompare(keyword,"filename") == 0)
7155 (void) CopyMagickString(msl_info->image[n]->filename,value,
7159 (void) SetMSLAttributes(msl_info,keyword,value);
7163 (void) SetMSLAttributes(msl_info,keyword,value);
7171 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7175 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7179 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7183 if ( value != NULL )
7184 value=DestroyString(value);
7185 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7188 static void MSLEndElement(void *context,const xmlChar *tag)
7197 Called when the end of an element has been detected.
7199 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7201 msl_info=(MSLInfo *) context;
7208 if (LocaleCompare((const char *) tag,"comment") == 0 )
7210 (void) DeleteImageProperty(msl_info->image[n],"comment");
7211 if (msl_info->content == (char *) NULL)
7213 StripString(msl_info->content);
7214 (void) SetImageProperty(msl_info->image[n],"comment",
7223 if (LocaleCompare((const char *) tag, "group") == 0 )
7225 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7228 (msl_info->group_info[msl_info->number_groups-1].numImages);
7231 if (msl_info->image[msl_info->n] != (Image *) NULL)
7232 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7233 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7234 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7238 msl_info->number_groups--;
7245 if (LocaleCompare((const char *) tag, "image") == 0)
7246 MSLPopImage(msl_info);
7252 if (LocaleCompare((const char *) tag,"label") == 0 )
7254 (void) DeleteImageProperty(msl_info->image[n],"label");
7255 if (msl_info->content == (char *) NULL)
7257 StripString(msl_info->content);
7258 (void) SetImageProperty(msl_info->image[n],"label",
7267 if (LocaleCompare((const char *) tag, "msl") == 0 )
7270 This our base element.
7271 at the moment we don't do anything special
7272 but someday we might!
7280 if (msl_info->content != (char *) NULL)
7281 msl_info->content=DestroyString(msl_info->content);
7284 static void MSLCharacters(void *context,const xmlChar *c,int length)
7296 Receiving some characters from the parser.
7298 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7299 " SAX.characters(%s,%d)",c,length);
7300 msl_info=(MSLInfo *) context;
7301 if (msl_info->content != (char *) NULL)
7302 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7303 strlen(msl_info->content)+length+MaxTextExtent,
7304 sizeof(*msl_info->content));
7307 msl_info->content=(char *) NULL;
7308 if (~length >= MaxTextExtent)
7309 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7310 sizeof(*msl_info->content));
7311 if (msl_info->content != (char *) NULL)
7312 *msl_info->content='\0';
7314 if (msl_info->content == (char *) NULL)
7316 p=msl_info->content+strlen(msl_info->content);
7317 for (i=0; i < length; i++)
7322 static void MSLReference(void *context,const xmlChar *name)
7331 Called when an entity reference is detected.
7333 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7334 " SAX.reference(%s)",name);
7335 msl_info=(MSLInfo *) context;
7336 parser=msl_info->parser;
7338 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7340 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7343 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7349 Receiving some ignorable whitespaces from the parser.
7351 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7352 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7353 msl_info=(MSLInfo *) context;
7356 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7357 const xmlChar *data)
7363 A processing instruction has been parsed.
7365 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7366 " SAX.processingInstruction(%s, %s)",
7368 msl_info=(MSLInfo *) context;
7371 static void MSLComment(void *context,const xmlChar *value)
7377 A comment has been parsed.
7379 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7380 " SAX.comment(%s)",value);
7381 msl_info=(MSLInfo *) context;
7384 static void MSLWarning(void *context,const char *format,...)
7388 reason[MaxTextExtent];
7397 Display and format a warning messages, gives file, line, position and
7400 va_start(operands,format);
7401 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7402 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7403 msl_info=(MSLInfo *) context;
7404 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7405 (void) vsprintf(reason,format,operands);
7407 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7409 message=GetExceptionMessage(errno);
7410 ThrowMSLException(CoderError,reason,message);
7411 message=DestroyString(message);
7415 static void MSLError(void *context,const char *format,...)
7418 reason[MaxTextExtent];
7427 Display and format a error formats, gives file, line, position and
7430 va_start(operands,format);
7431 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7432 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7433 msl_info=(MSLInfo *) context;
7434 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7435 (void) vsprintf(reason,format,operands);
7437 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7439 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7443 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7455 Called when a pcdata block has been parsed.
7457 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7458 " SAX.pcdata(%s, %d)",value,length);
7459 msl_info=(MSLInfo *) context;
7460 parser=msl_info->parser;
7461 child=xmlGetLastChild(parser->node);
7462 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7464 xmlTextConcat(child,value,length);
7467 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7470 static void MSLExternalSubset(void *context,const xmlChar *name,
7471 const xmlChar *external_id,const xmlChar *system_id)
7486 Does this document has an external subset?
7488 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7489 " SAX.externalSubset(%s %s %s)",name,
7490 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7491 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7492 msl_info=(MSLInfo *) context;
7493 parser=msl_info->parser;
7494 if (((external_id == NULL) && (system_id == NULL)) ||
7495 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7496 (msl_info->document == 0)))
7498 input=MSLResolveEntity(context,external_id,system_id);
7501 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7502 parser_context=(*parser);
7503 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7504 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7506 parser->errNo=XML_ERR_NO_MEMORY;
7507 parser->input=parser_context.input;
7508 parser->inputNr=parser_context.inputNr;
7509 parser->inputMax=parser_context.inputMax;
7510 parser->inputTab=parser_context.inputTab;
7516 xmlPushInput(parser,input);
7517 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7518 if (input->filename == (char *) NULL)
7519 input->filename=(char *) xmlStrdup(system_id);
7522 input->base=parser->input->cur;
7523 input->cur=parser->input->cur;
7525 xmlParseExternalSubset(parser,external_id,system_id);
7526 while (parser->inputNr > 1)
7527 (void) xmlPopInput(parser);
7528 xmlFreeInputStream(parser->input);
7529 xmlFree(parser->inputTab);
7530 parser->input=parser_context.input;
7531 parser->inputNr=parser_context.inputNr;
7532 parser->inputMax=parser_context.inputMax;
7533 parser->inputTab=parser_context.inputTab;
7536 #if defined(__cplusplus) || defined(c_plusplus)
7540 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7541 ExceptionInfo *exception)
7544 message[MaxTextExtent];
7567 assert(image_info != (const ImageInfo *) NULL);
7568 assert(image_info->signature == MagickSignature);
7569 if (image_info->debug != MagickFalse)
7570 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7571 image_info->filename);
7572 assert(image != (Image **) NULL);
7573 msl_image=AcquireImage(image_info);
7574 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7575 if (status == MagickFalse)
7577 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7578 msl_image->filename);
7579 msl_image=DestroyImageList(msl_image);
7580 return(MagickFalse);
7582 msl_image->columns=1;
7587 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7588 msl_info.exception=exception;
7589 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7590 sizeof(*msl_info.image_info));
7591 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7592 sizeof(*msl_info.draw_info));
7593 /* top of the stack is the MSL file itself */
7594 msl_info.image=(Image **) AcquireAlignedMemory(1,sizeof(*msl_info.image));
7595 msl_info.attributes=(Image **) AcquireMagickMemory(
7596 sizeof(*msl_info.attributes));
7597 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7598 sizeof(*msl_info.group_info));
7599 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7600 (msl_info.image == (Image **) NULL) ||
7601 (msl_info.attributes == (Image **) NULL) ||
7602 (msl_info.group_info == (MSLGroupInfo *) NULL))
7603 ThrowFatalException(ResourceLimitFatalError,
7604 "UnableToInterpretMSLImage");
7605 *msl_info.image_info=CloneImageInfo(image_info);
7606 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7607 *msl_info.attributes=AcquireImage(image_info);
7608 msl_info.group_info[0].numImages=0;
7609 /* the first slot is used to point to the MSL file image */
7610 *msl_info.image=msl_image;
7611 if (*image != (Image *) NULL)
7612 MSLPushImage(&msl_info,*image);
7613 (void) xmlSubstituteEntitiesDefault(1);
7614 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7615 sax_modules.internalSubset=MSLInternalSubset;
7616 sax_modules.isStandalone=MSLIsStandalone;
7617 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7618 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7619 sax_modules.resolveEntity=MSLResolveEntity;
7620 sax_modules.getEntity=MSLGetEntity;
7621 sax_modules.entityDecl=MSLEntityDeclaration;
7622 sax_modules.notationDecl=MSLNotationDeclaration;
7623 sax_modules.attributeDecl=MSLAttributeDeclaration;
7624 sax_modules.elementDecl=MSLElementDeclaration;
7625 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7626 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7627 sax_modules.startDocument=MSLStartDocument;
7628 sax_modules.endDocument=MSLEndDocument;
7629 sax_modules.startElement=MSLStartElement;
7630 sax_modules.endElement=MSLEndElement;
7631 sax_modules.reference=MSLReference;
7632 sax_modules.characters=MSLCharacters;
7633 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7634 sax_modules.processingInstruction=MSLProcessingInstructions;
7635 sax_modules.comment=MSLComment;
7636 sax_modules.warning=MSLWarning;
7637 sax_modules.error=MSLError;
7638 sax_modules.fatalError=MSLError;
7639 sax_modules.getParameterEntity=MSLGetParameterEntity;
7640 sax_modules.cdataBlock=MSLCDataBlock;
7641 sax_modules.externalSubset=MSLExternalSubset;
7642 sax_handler=(&sax_modules);
7643 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7644 msl_image->filename);
7645 while (ReadBlobString(msl_image,message) != (char *) NULL)
7647 n=(long) strlen(message);
7650 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7653 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7654 if (msl_info.exception->severity >= ErrorException)
7657 if (msl_info.exception->severity == UndefinedException)
7658 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7659 xmlFreeParserCtxt(msl_info.parser);
7660 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7662 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7663 msl_info.group_info);
7664 if (*image == (Image *) NULL)
7665 *image=(*msl_info.image);
7666 if ((*msl_info.image)->exception.severity != UndefinedException)
7667 return(MagickFalse);
7671 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7679 assert(image_info != (const ImageInfo *) NULL);
7680 assert(image_info->signature == MagickSignature);
7681 if (image_info->debug != MagickFalse)
7682 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7683 image_info->filename);
7684 assert(exception != (ExceptionInfo *) NULL);
7685 assert(exception->signature == MagickSignature);
7686 image=(Image *) NULL;
7687 (void) ProcessMSLScript(image_info,&image,exception);
7688 return(GetFirstImageInList(image));
7693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7697 % R e g i s t e r M S L I m a g e %
7701 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7703 % RegisterMSLImage() adds attributes for the MSL image format to
7704 % the list of supported formats. The attributes include the image format
7705 % tag, a method to read and/or write the format, whether the format
7706 % supports the saving of more than one frame to the same file or blob,
7707 % whether the format supports native in-memory I/O, and a brief
7708 % description of the format.
7710 % The format of the RegisterMSLImage method is:
7712 % unsigned long RegisterMSLImage(void)
7715 ModuleExport unsigned long RegisterMSLImage(void)
7720 entry=SetMagickInfo("MSL");
7721 #if defined(MAGICKCORE_XML_DELEGATE)
7722 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7723 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7725 entry->description=ConstantString("Magick Scripting Language");
7726 entry->module=ConstantString("MSL");
7727 (void) RegisterMagickInfo(entry);
7728 return(MagickImageCoderSignature);
7731 #if defined(MAGICKCORE_XML_DELEGATE)
7733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7737 % S e t M S L A t t r i b u t e s %
7741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7743 % SetMSLAttributes() ...
7745 % The format of the SetMSLAttributes method is:
7747 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7748 % const char *keyword,const char *value)
7750 % A description of each parameter follows:
7752 % o msl_info: the MSL info.
7754 % o keyword: the keyword.
7756 % o value: the value.
7759 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7786 assert(msl_info != (MSLInfo *) NULL);
7787 if (keyword == (const char *) NULL)
7789 if (value == (const char *) NULL)
7791 exception=msl_info->exception;
7793 attributes=msl_info->attributes[n];
7794 image_info=msl_info->image_info[n];
7795 draw_info=msl_info->draw_info[n];
7796 image=msl_info->image[n];
7802 if (LocaleCompare(keyword,"adjoin") == 0)
7807 adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7809 ThrowMSLException(OptionError,"UnrecognizedType",value);
7810 image_info->adjoin=(MagickBooleanType) adjoin;
7813 if (LocaleCompare(keyword,"alpha") == 0)
7818 alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
7820 ThrowMSLException(OptionError,"UnrecognizedType",value);
7821 if (image != (Image *) NULL)
7822 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7825 if (LocaleCompare(keyword,"antialias") == 0)
7830 antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7832 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7833 image_info->antialias=(MagickBooleanType) antialias;
7836 if (LocaleCompare(keyword,"area-limit") == 0)
7841 limit=MagickResourceInfinity;
7842 if (LocaleCompare(value,"unlimited") != 0)
7843 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7844 (void) SetMagickResourceLimit(AreaResource,limit);
7847 if (LocaleCompare(keyword,"attenuate") == 0)
7849 (void) SetImageOption(image_info,keyword,value);
7852 if (LocaleCompare(keyword,"authenticate") == 0)
7854 (void) CloneString(&image_info->density,value);
7857 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7863 if (LocaleCompare(keyword,"background") == 0)
7865 (void) QueryColorDatabase(value,&image_info->background_color,
7869 if (LocaleCompare(keyword,"bias") == 0)
7871 if (image == (Image *) NULL)
7873 image->bias=SiPrefixToDouble(value,QuantumRange);
7876 if (LocaleCompare(keyword,"blue-primary") == 0)
7878 if (image == (Image *) NULL)
7880 flags=ParseGeometry(value,&geometry_info);
7881 image->chromaticity.blue_primary.x=geometry_info.rho;
7882 image->chromaticity.blue_primary.y=geometry_info.sigma;
7883 if ((flags & SigmaValue) == 0)
7884 image->chromaticity.blue_primary.y=
7885 image->chromaticity.blue_primary.x;
7888 if (LocaleCompare(keyword,"bordercolor") == 0)
7890 (void) QueryColorDatabase(value,&image_info->border_color,
7894 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7900 if (LocaleCompare(keyword,"density") == 0)
7902 (void) CloneString(&image_info->density,value);
7903 (void) CloneString(&draw_info->density,value);
7906 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7912 if (LocaleCompare(keyword,"fill") == 0)
7914 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7915 (void) SetImageOption(image_info,keyword,value);
7918 if (LocaleCompare(keyword,"filename") == 0)
7920 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7923 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7929 if (LocaleCompare(keyword,"gravity") == 0)
7934 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
7936 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7937 (void) SetImageOption(image_info,keyword,value);
7940 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7946 if (LocaleCompare(keyword,"id") == 0)
7948 (void) SetImageProperty(attributes,keyword,value);
7951 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7957 if (LocaleCompare(keyword,"magick") == 0)
7959 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7962 if (LocaleCompare(keyword,"mattecolor") == 0)
7964 (void) QueryColorDatabase(value,&image_info->matte_color,
7968 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7974 if (LocaleCompare(keyword,"pointsize") == 0)
7976 image_info->pointsize=StringToDouble(value);
7977 draw_info->pointsize=StringToDouble(value);
7980 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7986 if (LocaleCompare(keyword,"quality") == 0)
7988 image_info->quality=StringToLong(value);
7989 if (image == (Image *) NULL)
7991 image->quality=StringToLong(value);
7999 if (LocaleCompare(keyword,"size") == 0)
8001 (void) CloneString(&image_info->size,value);
8004 if (LocaleCompare(keyword,"stroke") == 0)
8006 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8007 (void) SetImageOption(image_info,keyword,value);
8010 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8015 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8028 % U n r e g i s t e r M S L I m a g e %
8032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8034 % UnregisterMSLImage() removes format registrations made by the
8035 % MSL module from the list of supported formats.
8037 % The format of the UnregisterMSLImage method is:
8039 % UnregisterMSLImage(void)
8042 ModuleExport void UnregisterMSLImage(void)
8044 (void) UnregisterMagickInfo("MSL");
8047 #if defined(MAGICKCORE_XML_DELEGATE)
8049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8053 % W r i t e M S L I m a g e %
8057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8059 % WriteMSLImage() writes an image to a file in MVG image format.
8061 % The format of the WriteMSLImage method is:
8063 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8065 % A description of each parameter follows.
8067 % o image_info: the image info.
8069 % o image: The image.
8072 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8074 assert(image_info != (const ImageInfo *) NULL);
8075 assert(image_info->signature == MagickSignature);
8076 assert(image != (Image *) NULL);
8077 assert(image->signature == MagickSignature);
8078 if (image->debug != MagickFalse)
8079 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8080 (void) ReferenceImage(image);
8081 (void) ProcessMSLScript(image_info,&image,&image->exception);