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(MAGICKCORE_WINDOWS_SUPPORT)
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,
1065 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1066 geometry.height,(double) geometry.x,(double) geometry.y);
1067 CloneString(&draw_info->geometry,text);
1068 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1069 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1070 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1071 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1072 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1074 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1076 (void) AnnotateImage(msl_info->image[n],draw_info);
1077 draw_info=DestroyDrawInfo(draw_info);
1080 if (LocaleCompare((const char *) tag,"append") == 0)
1088 if (msl_info->image[n] == (Image *) NULL)
1090 ThrowMSLException(OptionError,"NoImagesDefined",
1091 (const char *) tag);
1095 if (attributes != (const xmlChar **) NULL)
1096 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1098 keyword=(const char *) attributes[i++];
1099 attribute=InterpretImageProperties(msl_info->image_info[n],
1100 msl_info->attributes[n],(const char *) attributes[i]);
1101 CloneString(&value,attribute);
1107 if (LocaleCompare(keyword,"stack") == 0)
1109 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1112 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1114 stack=(MagickBooleanType) option;
1117 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1129 append_image=AppendImages(msl_info->image[n],stack,
1130 &msl_info->image[n]->exception);
1131 if (append_image == (Image *) NULL)
1133 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1134 msl_info->image[n]=append_image;
1137 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1143 if (LocaleCompare((const char *) tag,"blur") == 0)
1151 if (msl_info->image[n] == (Image *) NULL)
1153 ThrowMSLException(OptionError,"NoImagesDefined",
1154 (const char *) tag);
1157 if (attributes != (const xmlChar **) NULL)
1158 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1160 keyword=(const char *) attributes[i++];
1161 attribute=InterpretImageProperties(msl_info->image_info[n],
1162 msl_info->attributes[n],(const char *) attributes[i]);
1163 CloneString(&value,attribute);
1169 if (LocaleCompare(keyword,"channel") == 0)
1171 option=ParseChannelOption(value);
1173 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1175 channel=(ChannelType) option;
1178 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1185 if (LocaleCompare(keyword,"geometry") == 0)
1187 flags=ParseGeometry(value,&geometry_info);
1188 if ((flags & SigmaValue) == 0)
1189 geometry_info.sigma=1.0;
1192 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1199 if (LocaleCompare(keyword,"radius") == 0)
1201 geometry_info.rho=StringToDouble(value);
1204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1211 if (LocaleCompare(keyword,"sigma") == 0)
1213 geometry_info.sigma=StringToLong(value);
1216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1228 blur_image=BlurImageChannel(msl_info->image[n],channel,
1229 geometry_info.rho,geometry_info.sigma,
1230 &msl_info->image[n]->exception);
1231 if (blur_image == (Image *) NULL)
1233 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1234 msl_info->image[n]=blur_image;
1237 if (LocaleCompare((const char *) tag,"border") == 0)
1245 if (msl_info->image[n] == (Image *) NULL)
1247 ThrowMSLException(OptionError,"NoImagesDefined",
1248 (const char *) tag);
1251 SetGeometry(msl_info->image[n],&geometry);
1252 if (attributes != (const xmlChar **) NULL)
1253 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1255 keyword=(const char *) attributes[i++];
1256 attribute=InterpretImageProperties(msl_info->image_info[n],
1257 msl_info->attributes[n],(const char *) attributes[i]);
1258 CloneString(&value,attribute);
1264 if (LocaleCompare(keyword,"compose") == 0)
1266 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1269 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1271 msl_info->image[n]->compose=(CompositeOperator) option;
1274 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1281 if (LocaleCompare(keyword, "fill") == 0)
1283 (void) QueryColorDatabase(value,
1284 &msl_info->image[n]->border_color,&exception);
1287 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1294 if (LocaleCompare(keyword,"geometry") == 0)
1296 flags=ParsePageGeometry(msl_info->image[n],value,
1297 &geometry,&exception);
1298 if ((flags & HeightValue) == 0)
1299 geometry.height=geometry.width;
1302 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1309 if (LocaleCompare(keyword,"height") == 0)
1311 geometry.height=StringToLong(value);
1314 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1321 if (LocaleCompare(keyword,"width") == 0)
1323 geometry.width=StringToLong(value);
1326 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1332 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 border_image=BorderImage(msl_info->image[n],&geometry,
1339 &msl_info->image[n]->exception);
1340 if (border_image == (Image *) NULL)
1342 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1343 msl_info->image[n]=border_image;
1346 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1351 if (LocaleCompare((const char *) tag,"colorize") == 0)
1354 opacity[MaxTextExtent];
1365 if (msl_info->image[n] == (Image *) NULL)
1367 ThrowMSLException(OptionError,"NoImagesDefined",
1368 (const char *) tag);
1371 target=msl_info->image[n]->background_color;
1372 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1373 if (attributes != (const xmlChar **) NULL)
1374 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1376 keyword=(const char *) attributes[i++];
1377 attribute=InterpretImageProperties(msl_info->image_info[n],
1378 msl_info->attributes[n],(const char *) attributes[i]);
1379 CloneString(&value,attribute);
1385 if (LocaleCompare(keyword,"fill") == 0)
1387 (void) QueryColorDatabase(value,&target,
1388 &msl_info->image[n]->exception);
1391 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1398 if (LocaleCompare(keyword,"opacity") == 0)
1400 (void) CopyMagickString(opacity,value,MaxTextExtent);
1403 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1409 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1416 &msl_info->image[n]->exception);
1417 if (colorize_image == (Image *) NULL)
1419 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1420 msl_info->image[n]=colorize_image;
1423 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1425 double radius = 0.0,
1428 if (msl_info->image[n] == (Image *) NULL)
1430 ThrowMSLException(OptionError,"NoImagesDefined",
1431 (const char *) tag);
1435 NOTE: charcoal can have no attributes, since we use all the defaults!
1437 if (attributes != (const xmlChar **) NULL)
1439 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1441 keyword=(const char *) attributes[i++];
1442 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1443 msl_info->attributes[n],(const char *) attributes[i]));
1449 if (LocaleCompare(keyword, "radius") == 0)
1451 radius = StringToDouble( value );
1454 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1460 if (LocaleCompare(keyword,"sigma") == 0)
1462 sigma = StringToLong( value );
1465 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1470 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1484 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1485 &msl_info->image[n]->exception);
1486 if (newImage == (Image *) NULL)
1488 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1489 msl_info->image[n]=newImage;
1493 if (LocaleCompare((const char *) tag,"chop") == 0)
1501 if (msl_info->image[n] == (Image *) NULL)
1503 ThrowMSLException(OptionError,"NoImagesDefined",
1504 (const char *) tag);
1507 SetGeometry(msl_info->image[n],&geometry);
1508 if (attributes != (const xmlChar **) NULL)
1509 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1511 keyword=(const char *) attributes[i++];
1512 attribute=InterpretImageProperties(msl_info->image_info[n],
1513 msl_info->attributes[n],(const char *) attributes[i]);
1514 CloneString(&value,attribute);
1520 if (LocaleCompare(keyword,"geometry") == 0)
1522 flags=ParsePageGeometry(msl_info->image[n],value,
1523 &geometry,&exception);
1524 if ((flags & HeightValue) == 0)
1525 geometry.height=geometry.width;
1528 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1535 if (LocaleCompare(keyword,"height") == 0)
1537 geometry.height=StringToLong(value);
1540 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1547 if (LocaleCompare(keyword,"width") == 0)
1549 geometry.width=StringToLong(value);
1552 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1559 if (LocaleCompare(keyword,"x") == 0)
1561 geometry.x=StringToLong(value);
1564 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1571 if (LocaleCompare(keyword,"y") == 0)
1573 geometry.y=StringToLong(value);
1576 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1588 chop_image=ChopImage(msl_info->image[n],&geometry,
1589 &msl_info->image[n]->exception);
1590 if (chop_image == (Image *) NULL)
1592 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1593 msl_info->image[n]=chop_image;
1596 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1605 Color floodfill image.
1607 if (msl_info->image[n] == (Image *) NULL)
1609 ThrowMSLException(OptionError,"NoImagesDefined",
1610 (const char *) tag);
1613 draw_info=CloneDrawInfo(msl_info->image_info[n],
1614 msl_info->draw_info[n]);
1615 SetGeometry(msl_info->image[n],&geometry);
1616 paint_method=FloodfillMethod;
1617 if (attributes != (const xmlChar **) NULL)
1618 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1620 keyword=(const char *) attributes[i++];
1621 attribute=InterpretImageProperties(msl_info->image_info[n],
1622 msl_info->attributes[n],(const char *) attributes[i]);
1623 CloneString(&value,attribute);
1629 if (LocaleCompare(keyword,"bordercolor") == 0)
1631 (void) QueryMagickColor(value,&target,&exception);
1632 paint_method=FillToBorderMethod;
1635 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1642 if (LocaleCompare(keyword,"fill") == 0)
1644 (void) QueryColorDatabase(value,&draw_info->fill,
1648 if (LocaleCompare(keyword,"fuzz") == 0)
1650 msl_info->image[n]->fuzz=StringToDouble(value);
1653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1660 if (LocaleCompare(keyword,"geometry") == 0)
1662 flags=ParsePageGeometry(msl_info->image[n],value,
1663 &geometry,&exception);
1664 if ((flags & HeightValue) == 0)
1665 geometry.height=geometry.width;
1666 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1667 geometry.x,geometry.y,&target,&exception);
1670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1677 if (LocaleCompare(keyword,"x") == 0)
1679 geometry.x=StringToLong(value);
1680 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1681 geometry.x,geometry.y,&target,&exception);
1684 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1691 if (LocaleCompare(keyword,"y") == 0)
1693 geometry.y=StringToLong(value);
1694 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1695 geometry.x,geometry.y,&target,&exception);
1698 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1710 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1711 draw_info,&target,geometry.x,geometry.y,
1712 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1713 draw_info=DestroyDrawInfo(draw_info);
1716 if (LocaleCompare((const char *) tag,"comment") == 0)
1718 if (LocaleCompare((const char *) tag,"composite") == 0)
1721 composite_geometry[MaxTextExtent];
1736 if (msl_info->image[n] == (Image *) NULL)
1738 ThrowMSLException(OptionError,"NoImagesDefined",
1739 (const char *) tag);
1742 composite_image=NewImageList();
1743 compose=OverCompositeOp;
1744 if (attributes != (const xmlChar **) NULL)
1745 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1747 keyword=(const char *) attributes[i++];
1748 attribute=InterpretImageProperties(msl_info->image_info[n],
1749 msl_info->attributes[n],(const char *) attributes[i]);
1750 CloneString(&value,attribute);
1756 if (LocaleCompare(keyword,"compose") == 0)
1758 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1761 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1763 compose=(CompositeOperator) option;
1771 if (LocaleCompare(keyword,"image") == 0)
1772 for (j=0; j < msl_info->n; j++)
1777 attribute=GetImageProperty(msl_info->attributes[j],"id");
1778 if ((attribute != (const char *) NULL) &&
1779 (LocaleCompare(attribute,value) == 0))
1781 composite_image=CloneImage(msl_info->image[j],0,0,
1782 MagickFalse,&exception);
1792 if (composite_image == (Image *) NULL)
1794 rotate_image=NewImageList();
1795 SetGeometry(msl_info->image[n],&geometry);
1796 if (attributes != (const xmlChar **) NULL)
1797 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1799 keyword=(const char *) attributes[i++];
1800 attribute=InterpretImageProperties(msl_info->image_info[n],
1801 msl_info->attributes[n],(const char *) attributes[i]);
1802 CloneString(&value,attribute);
1808 if (LocaleCompare(keyword,"blend") == 0)
1810 (void) SetImageArtifact(composite_image,
1811 "compose:args",value);
1814 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1821 if (LocaleCompare(keyword,"channel") == 0)
1823 option=ParseChannelOption(value);
1825 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1827 channel=(ChannelType) option;
1830 if (LocaleCompare(keyword, "color") == 0)
1832 (void) QueryColorDatabase(value,
1833 &composite_image->background_color,&exception);
1836 if (LocaleCompare(keyword,"compose") == 0)
1838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1845 if (LocaleCompare(keyword,"geometry") == 0)
1847 flags=ParsePageGeometry(msl_info->image[n],value,
1848 &geometry,&exception);
1849 if ((flags & HeightValue) == 0)
1850 geometry.height=geometry.width;
1851 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1852 geometry.y,&target,&exception);
1855 if (LocaleCompare(keyword,"gravity") == 0)
1857 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
1860 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1862 msl_info->image[n]->gravity=(GravityType) option;
1865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1872 if (LocaleCompare(keyword,"image") == 0)
1874 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1881 if (LocaleCompare(keyword,"mask") == 0)
1882 for (j=0; j < msl_info->n; j++)
1887 attribute=GetImageProperty(msl_info->attributes[j],"id");
1888 if ((attribute != (const char *) NULL) &&
1889 (LocaleCompare(value,value) == 0))
1891 SetImageType(composite_image,TrueColorMatteType);
1892 (void) CompositeImage(composite_image,
1893 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1897 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1904 if (LocaleCompare(keyword,"opacity") == 0)
1913 register PixelPacket
1919 opacity=QuantumRange-StringToLong(value);
1920 if (compose != DissolveCompositeOp)
1922 (void) SetImageOpacity(composite_image,(Quantum)
1926 (void) SetImageArtifact(msl_info->image[n],
1927 "compose:args",value);
1928 if (composite_image->matte != MagickTrue)
1929 (void) SetImageOpacity(composite_image,OpaqueOpacity);
1930 composite_view=AcquireCacheView(composite_image);
1931 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1933 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
1934 composite_image->columns,1,&exception);
1935 for (x=0; x < (ssize_t) composite_image->columns; x++)
1937 if (q->opacity == OpaqueOpacity)
1938 q->opacity=ClampToQuantum(opacity);
1941 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1944 composite_view=DestroyCacheView(composite_view);
1947 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1954 if (LocaleCompare(keyword,"rotate") == 0)
1956 rotate_image=RotateImage(composite_image,StringToDouble(value),
1960 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1967 if (LocaleCompare(keyword,"tile") == 0)
1972 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1975 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1977 tile=(MagickBooleanType) option;
1978 if (rotate_image != (Image *) NULL)
1979 (void) SetImageArtifact(rotate_image,
1980 "compose:outside-overlay","false");
1982 (void) SetImageArtifact(composite_image,
1983 "compose:outside-overlay","false");
1984 image=msl_info->image[n];
1985 height=composite_image->rows;
1986 width=composite_image->columns;
1987 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1988 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1990 if (rotate_image != (Image *) NULL)
1991 (void) CompositeImage(image,compose,rotate_image,
1994 (void) CompositeImage(image,compose,
1995 composite_image,x,y);
1997 if (rotate_image != (Image *) NULL)
1998 rotate_image=DestroyImage(rotate_image);
2001 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2008 if (LocaleCompare(keyword,"x") == 0)
2010 geometry.x=StringToLong(value);
2011 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2012 geometry.y,&target,&exception);
2015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2022 if (LocaleCompare(keyword,"y") == 0)
2024 geometry.y=StringToLong(value);
2025 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2026 geometry.y,&target,&exception);
2029 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2035 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2041 image=msl_info->image[n];
2042 (void) FormatMagickString(composite_geometry,MaxTextExtent,
2043 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2044 (double) composite_image->rows,(double) geometry.x,(double)
2046 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2048 if (rotate_image == (Image *) NULL)
2049 CompositeImageChannel(image,channel,compose,composite_image,
2050 geometry.x,geometry.y);
2056 geometry.x-=(ssize_t) (rotate_image->columns-
2057 composite_image->columns)/2;
2058 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2059 CompositeImageChannel(image,channel,compose,rotate_image,
2060 geometry.x,geometry.y);
2061 rotate_image=DestroyImage(rotate_image);
2063 composite_image=DestroyImage(composite_image);
2066 if (LocaleCompare((const char *) tag,"contrast") == 0)
2074 if (msl_info->image[n] == (Image *) NULL)
2076 ThrowMSLException(OptionError,"NoImagesDefined",
2077 (const char *) tag);
2080 sharpen=MagickFalse;
2081 if (attributes != (const xmlChar **) NULL)
2082 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2084 keyword=(const char *) attributes[i++];
2085 attribute=InterpretImageProperties(msl_info->image_info[n],
2086 msl_info->attributes[n],(const char *) attributes[i]);
2087 CloneString(&value,attribute);
2093 if (LocaleCompare(keyword,"sharpen") == 0)
2095 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2098 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2100 sharpen=(MagickBooleanType) option;
2103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2109 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2115 (void) ContrastImage(msl_info->image[n],sharpen);
2118 if (LocaleCompare((const char *) tag,"crop") == 0)
2126 if (msl_info->image[n] == (Image *) NULL)
2128 ThrowMSLException(OptionError,"NoImagesDefined",
2129 (const char *) tag);
2132 SetGeometry(msl_info->image[n],&geometry);
2133 if (attributes != (const xmlChar **) NULL)
2134 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2136 keyword=(const char *) attributes[i++];
2137 attribute=InterpretImageProperties(msl_info->image_info[n],
2138 msl_info->attributes[n],(const char *) attributes[i]);
2139 CloneString(&value,attribute);
2145 if (LocaleCompare(keyword,"geometry") == 0)
2147 flags=ParsePageGeometry(msl_info->image[n],value,
2148 &geometry,&exception);
2149 if ((flags & HeightValue) == 0)
2150 geometry.height=geometry.width;
2153 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2160 if (LocaleCompare(keyword,"height") == 0)
2162 geometry.height=StringToLong(value);
2165 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2172 if (LocaleCompare(keyword,"width") == 0)
2174 geometry.width=StringToLong(value);
2177 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2184 if (LocaleCompare(keyword,"x") == 0)
2186 geometry.x=StringToLong(value);
2189 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2196 if (LocaleCompare(keyword,"y") == 0)
2198 geometry.y=StringToLong(value);
2201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2213 crop_image=CropImage(msl_info->image[n],&geometry,
2214 &msl_info->image[n]->exception);
2215 if (crop_image == (Image *) NULL)
2217 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2218 msl_info->image[n]=crop_image;
2221 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2227 Cycle-colormap image.
2229 if (msl_info->image[n] == (Image *) NULL)
2231 ThrowMSLException(OptionError,"NoImagesDefined",
2232 (const char *) tag);
2236 if (attributes != (const xmlChar **) NULL)
2237 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2239 keyword=(const char *) attributes[i++];
2240 attribute=InterpretImageProperties(msl_info->image_info[n],
2241 msl_info->attributes[n],(const char *) attributes[i]);
2242 CloneString(&value,attribute);
2248 if (LocaleCompare(keyword,"display") == 0)
2250 display=StringToLong(value);
2253 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2259 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2265 (void) CycleColormapImage(msl_info->image[n],display);
2268 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2273 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2281 if (msl_info->image[n] == (Image *) NULL)
2283 ThrowMSLException(OptionError,"NoImagesDefined",
2284 (const char *) tag);
2287 if (attributes != (const xmlChar **) NULL)
2288 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2290 keyword=(const char *) attributes[i++];
2291 attribute=InterpretImageProperties(msl_info->image_info[n],
2292 msl_info->attributes[n],(const char *) attributes[i]);
2293 CloneString(&value,attribute);
2294 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2296 despeckle_image=DespeckleImage(msl_info->image[n],
2297 &msl_info->image[n]->exception);
2298 if (despeckle_image == (Image *) NULL)
2300 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2301 msl_info->image[n]=despeckle_image;
2304 if (LocaleCompare((const char *) tag,"display") == 0)
2306 if (msl_info->image[n] == (Image *) NULL)
2308 ThrowMSLException(OptionError,"NoImagesDefined",
2309 (const char *) tag);
2312 if (attributes != (const xmlChar **) NULL)
2313 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2315 keyword=(const char *) attributes[i++];
2316 attribute=InterpretImageProperties(msl_info->image_info[n],
2317 msl_info->attributes[n],(const char *) attributes[i]);
2318 CloneString(&value,attribute);
2323 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2329 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2332 if (LocaleCompare((const char *) tag,"draw") == 0)
2335 text[MaxTextExtent];
2340 if (msl_info->image[n] == (Image *) NULL)
2342 ThrowMSLException(OptionError,"NoImagesDefined",
2343 (const char *) tag);
2346 draw_info=CloneDrawInfo(msl_info->image_info[n],
2347 msl_info->draw_info[n]);
2349 current=draw_info->affine;
2350 GetAffineMatrix(&affine);
2351 if (attributes != (const xmlChar **) NULL)
2352 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2354 keyword=(const char *) attributes[i++];
2355 attribute=InterpretImageProperties(msl_info->image_info[n],
2356 msl_info->attributes[n],(const char *) attributes[i]);
2357 CloneString(&value,attribute);
2363 if (LocaleCompare(keyword,"affine") == 0)
2369 draw_info->affine.sx=strtod(p,&p);
2372 draw_info->affine.rx=strtod(p,&p);
2375 draw_info->affine.ry=strtod(p,&p);
2378 draw_info->affine.sy=strtod(p,&p);
2381 draw_info->affine.tx=strtod(p,&p);
2384 draw_info->affine.ty=strtod(p,&p);
2387 if (LocaleCompare(keyword,"align") == 0)
2389 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
2392 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2394 draw_info->align=(AlignType) option;
2397 if (LocaleCompare(keyword,"antialias") == 0)
2399 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2402 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2404 draw_info->stroke_antialias=(MagickBooleanType) option;
2405 draw_info->text_antialias=(MagickBooleanType) option;
2408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2415 if (LocaleCompare(keyword,"density") == 0)
2417 CloneString(&draw_info->density,value);
2420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2427 if (LocaleCompare(keyword,"encoding") == 0)
2429 CloneString(&draw_info->encoding,value);
2432 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2439 if (LocaleCompare(keyword, "fill") == 0)
2441 (void) QueryColorDatabase(value,&draw_info->fill,
2445 if (LocaleCompare(keyword,"family") == 0)
2447 CloneString(&draw_info->family,value);
2450 if (LocaleCompare(keyword,"font") == 0)
2452 CloneString(&draw_info->font,value);
2455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2462 if (LocaleCompare(keyword,"geometry") == 0)
2464 flags=ParsePageGeometry(msl_info->image[n],value,
2465 &geometry,&exception);
2466 if ((flags & HeightValue) == 0)
2467 geometry.height=geometry.width;
2470 if (LocaleCompare(keyword,"gravity") == 0)
2472 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
2475 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2477 draw_info->gravity=(GravityType) option;
2480 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2487 if (LocaleCompare(keyword,"primitive") == 0)
2489 CloneString(&draw_info->primitive,value);
2492 if (LocaleCompare(keyword,"pointsize") == 0)
2494 draw_info->pointsize=StringToDouble(value);
2497 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2504 if (LocaleCompare(keyword,"rotate") == 0)
2506 angle=StringToDouble(value);
2507 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2508 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2509 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2510 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2513 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2520 if (LocaleCompare(keyword,"scale") == 0)
2522 flags=ParseGeometry(value,&geometry_info);
2523 if ((flags & SigmaValue) == 0)
2524 geometry_info.sigma=1.0;
2525 affine.sx=geometry_info.rho;
2526 affine.sy=geometry_info.sigma;
2529 if (LocaleCompare(keyword,"skewX") == 0)
2531 angle=StringToDouble(value);
2532 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2535 if (LocaleCompare(keyword,"skewY") == 0)
2537 angle=StringToDouble(value);
2538 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2541 if (LocaleCompare(keyword,"stretch") == 0)
2543 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
2546 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2548 draw_info->stretch=(StretchType) option;
2551 if (LocaleCompare(keyword, "stroke") == 0)
2553 (void) QueryColorDatabase(value,&draw_info->stroke,
2557 if (LocaleCompare(keyword,"strokewidth") == 0)
2559 draw_info->stroke_width=StringToLong(value);
2562 if (LocaleCompare(keyword,"style") == 0)
2564 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
2567 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2569 draw_info->style=(StyleType) option;
2572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2579 if (LocaleCompare(keyword,"text") == 0)
2581 CloneString(&draw_info->text,value);
2584 if (LocaleCompare(keyword,"translate") == 0)
2586 flags=ParseGeometry(value,&geometry_info);
2587 if ((flags & SigmaValue) == 0)
2588 geometry_info.sigma=1.0;
2589 affine.tx=geometry_info.rho;
2590 affine.ty=geometry_info.sigma;
2593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2600 if (LocaleCompare(keyword, "undercolor") == 0)
2602 (void) QueryColorDatabase(value,&draw_info->undercolor,
2606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2613 if (LocaleCompare(keyword,"weight") == 0)
2615 draw_info->weight=StringToLong(value);
2618 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2625 if (LocaleCompare(keyword,"x") == 0)
2627 geometry.x=StringToLong(value);
2630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2637 if (LocaleCompare(keyword,"y") == 0)
2639 geometry.y=StringToLong(value);
2642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2648 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2654 (void) FormatMagickString(text,MaxTextExtent,
2655 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2656 geometry.height,(double) geometry.x,(double) geometry.y);
2657 CloneString(&draw_info->geometry,text);
2658 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2659 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2660 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2661 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2662 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2664 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2666 (void) DrawImage(msl_info->image[n],draw_info);
2667 draw_info=DestroyDrawInfo(draw_info);
2670 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2675 if (LocaleCompare((const char *) tag,"edge") == 0)
2683 if (msl_info->image[n] == (Image *) NULL)
2685 ThrowMSLException(OptionError,"NoImagesDefined",
2686 (const char *) tag);
2689 if (attributes != (const xmlChar **) NULL)
2690 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2692 keyword=(const char *) attributes[i++];
2693 attribute=InterpretImageProperties(msl_info->image_info[n],
2694 msl_info->attributes[n],(const char *) attributes[i]);
2695 CloneString(&value,attribute);
2701 if (LocaleCompare(keyword,"geometry") == 0)
2703 flags=ParseGeometry(value,&geometry_info);
2704 if ((flags & SigmaValue) == 0)
2705 geometry_info.sigma=1.0;
2708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2715 if (LocaleCompare(keyword,"radius") == 0)
2717 geometry_info.rho=StringToDouble(value);
2720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2732 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2733 &msl_info->image[n]->exception);
2734 if (edge_image == (Image *) NULL)
2736 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2737 msl_info->image[n]=edge_image;
2740 if (LocaleCompare((const char *) tag,"emboss") == 0)
2748 if (msl_info->image[n] == (Image *) NULL)
2750 ThrowMSLException(OptionError,"NoImagesDefined",
2751 (const char *) tag);
2754 if (attributes != (const xmlChar **) NULL)
2755 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2757 keyword=(const char *) attributes[i++];
2758 attribute=InterpretImageProperties(msl_info->image_info[n],
2759 msl_info->attributes[n],(const char *) attributes[i]);
2760 CloneString(&value,attribute);
2766 if (LocaleCompare(keyword,"geometry") == 0)
2768 flags=ParseGeometry(value,&geometry_info);
2769 if ((flags & SigmaValue) == 0)
2770 geometry_info.sigma=1.0;
2773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2780 if (LocaleCompare(keyword,"radius") == 0)
2782 geometry_info.rho=StringToDouble(value);
2785 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2792 if (LocaleCompare(keyword,"sigma") == 0)
2794 geometry_info.sigma=StringToLong(value);
2797 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2809 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2810 geometry_info.sigma,&msl_info->image[n]->exception);
2811 if (emboss_image == (Image *) NULL)
2813 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2814 msl_info->image[n]=emboss_image;
2817 if (LocaleCompare((const char *) tag,"enhance") == 0)
2825 if (msl_info->image[n] == (Image *) NULL)
2827 ThrowMSLException(OptionError,"NoImagesDefined",
2828 (const char *) tag);
2831 if (attributes != (const xmlChar **) NULL)
2832 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2834 keyword=(const char *) attributes[i++];
2835 attribute=InterpretImageProperties(msl_info->image_info[n],
2836 msl_info->attributes[n],(const char *) attributes[i]);
2837 CloneString(&value,attribute);
2838 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2840 enhance_image=EnhanceImage(msl_info->image[n],
2841 &msl_info->image[n]->exception);
2842 if (enhance_image == (Image *) NULL)
2844 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2845 msl_info->image[n]=enhance_image;
2848 if (LocaleCompare((const char *) tag,"equalize") == 0)
2853 if (msl_info->image[n] == (Image *) NULL)
2855 ThrowMSLException(OptionError,"NoImagesDefined",
2856 (const char *) tag);
2859 if (attributes != (const xmlChar **) NULL)
2860 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2862 keyword=(const char *) attributes[i++];
2863 attribute=InterpretImageProperties(msl_info->image_info[n],
2864 msl_info->attributes[n],(const char *) attributes[i]);
2865 CloneString(&value,attribute);
2870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2876 (void) EqualizeImage(msl_info->image[n]);
2879 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2884 if (LocaleCompare((const char *) tag, "flatten") == 0)
2886 if (msl_info->image[n] == (Image *) NULL)
2888 ThrowMSLException(OptionError,"NoImagesDefined",
2889 (const char *) tag);
2893 /* no attributes here */
2895 /* process the image */
2900 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2901 &msl_info->image[n]->exception);
2902 if (newImage == (Image *) NULL)
2904 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2905 msl_info->image[n]=newImage;
2909 if (LocaleCompare((const char *) tag,"flip") == 0)
2917 if (msl_info->image[n] == (Image *) NULL)
2919 ThrowMSLException(OptionError,"NoImagesDefined",
2920 (const char *) tag);
2923 if (attributes != (const xmlChar **) NULL)
2924 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2926 keyword=(const char *) attributes[i++];
2927 attribute=InterpretImageProperties(msl_info->image_info[n],
2928 msl_info->attributes[n],(const char *) attributes[i]);
2929 CloneString(&value,attribute);
2930 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2932 flip_image=FlipImage(msl_info->image[n],
2933 &msl_info->image[n]->exception);
2934 if (flip_image == (Image *) NULL)
2936 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2937 msl_info->image[n]=flip_image;
2940 if (LocaleCompare((const char *) tag,"flop") == 0)
2948 if (msl_info->image[n] == (Image *) NULL)
2950 ThrowMSLException(OptionError,"NoImagesDefined",
2951 (const char *) tag);
2954 if (attributes != (const xmlChar **) NULL)
2955 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2957 keyword=(const char *) attributes[i++];
2958 attribute=InterpretImageProperties(msl_info->image_info[n],
2959 msl_info->attributes[n],(const char *) attributes[i]);
2960 CloneString(&value,attribute);
2961 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2963 flop_image=FlopImage(msl_info->image[n],
2964 &msl_info->image[n]->exception);
2965 if (flop_image == (Image *) NULL)
2967 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2968 msl_info->image[n]=flop_image;
2971 if (LocaleCompare((const char *) tag,"frame") == 0)
2982 if (msl_info->image[n] == (Image *) NULL)
2984 ThrowMSLException(OptionError,"NoImagesDefined",
2985 (const char *) tag);
2988 SetGeometry(msl_info->image[n],&geometry);
2989 if (attributes != (const xmlChar **) NULL)
2990 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2992 keyword=(const char *) attributes[i++];
2993 attribute=InterpretImageProperties(msl_info->image_info[n],
2994 msl_info->attributes[n],(const char *) attributes[i]);
2995 CloneString(&value,attribute);
3001 if (LocaleCompare(keyword,"compose") == 0)
3003 option=ParseMagickOption(MagickComposeOptions,
3006 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3008 msl_info->image[n]->compose=(CompositeOperator) option;
3011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3018 if (LocaleCompare(keyword, "fill") == 0)
3020 (void) QueryColorDatabase(value,
3021 &msl_info->image[n]->matte_color,&exception);
3024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3031 if (LocaleCompare(keyword,"geometry") == 0)
3033 flags=ParsePageGeometry(msl_info->image[n],value,
3034 &geometry,&exception);
3035 if ((flags & HeightValue) == 0)
3036 geometry.height=geometry.width;
3037 frame_info.width=geometry.width;
3038 frame_info.height=geometry.height;
3039 frame_info.outer_bevel=geometry.x;
3040 frame_info.inner_bevel=geometry.y;
3043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3050 if (LocaleCompare(keyword,"height") == 0)
3052 frame_info.height=StringToLong(value);
3055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3062 if (LocaleCompare(keyword,"inner") == 0)
3064 frame_info.inner_bevel=StringToLong(value);
3067 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3074 if (LocaleCompare(keyword,"outer") == 0)
3076 frame_info.outer_bevel=StringToLong(value);
3079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3086 if (LocaleCompare(keyword,"width") == 0)
3088 frame_info.width=StringToLong(value);
3091 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3103 frame_info.x=(ssize_t) frame_info.width;
3104 frame_info.y=(ssize_t) frame_info.height;
3105 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3106 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3107 frame_image=FrameImage(msl_info->image[n],&frame_info,
3108 &msl_info->image[n]->exception);
3109 if (frame_image == (Image *) NULL)
3111 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3112 msl_info->image[n]=frame_image;
3115 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3120 if (LocaleCompare((const char *) tag,"gamma") == 0)
3123 gamma[MaxTextExtent];
3131 if (msl_info->image[n] == (Image *) NULL)
3133 ThrowMSLException(OptionError,"NoImagesDefined",
3134 (const char *) tag);
3137 channel=UndefinedChannel;
3142 if (attributes != (const xmlChar **) NULL)
3143 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3145 keyword=(const char *) attributes[i++];
3146 attribute=InterpretImageProperties(msl_info->image_info[n],
3147 msl_info->attributes[n],(const char *) attributes[i]);
3148 CloneString(&value,attribute);
3154 if (LocaleCompare(keyword,"blue") == 0)
3156 pixel.blue=StringToDouble(value);
3159 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3166 if (LocaleCompare(keyword,"channel") == 0)
3168 option=ParseChannelOption(value);
3170 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3172 channel=(ChannelType) option;
3175 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3182 if (LocaleCompare(keyword,"gamma") == 0)
3184 (void) CopyMagickString(gamma,value,MaxTextExtent);
3187 if (LocaleCompare(keyword,"green") == 0)
3189 pixel.green=StringToDouble(value);
3192 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3199 if (LocaleCompare(keyword,"red") == 0)
3201 pixel.red=StringToDouble(value);
3204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3217 (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
3218 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3223 (void) GammaImage(msl_info->image[n],gamma);
3228 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3233 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3239 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3246 else if (LocaleCompare((const char *) tag,"get") == 0)
3248 if (msl_info->image[n] == (Image *) NULL)
3250 ThrowMSLException(OptionError,"NoImagesDefined",
3251 (const char *) tag);
3254 if (attributes == (const xmlChar **) NULL)
3256 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3258 keyword=(const char *) attributes[i++];
3259 CloneString(&value,(const char *) attributes[i]);
3260 (void) CopyMagickString(key,value,MaxTextExtent);
3266 if (LocaleCompare(keyword,"height") == 0)
3268 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3269 (double) msl_info->image[n]->rows);
3270 (void) SetImageProperty(msl_info->attributes[n],key,value);
3273 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3278 if (LocaleCompare(keyword,"width") == 0)
3280 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3281 (double) msl_info->image[n]->columns);
3282 (void) SetImageProperty(msl_info->attributes[n],key,value);
3285 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3289 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3296 else if (LocaleCompare((const char *) tag, "group") == 0)
3298 msl_info->number_groups++;
3299 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3300 msl_info->group_info,msl_info->number_groups+1UL,
3301 sizeof(*msl_info->group_info));
3304 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3309 if (LocaleCompare((const char *) tag,"image") == 0)
3311 MSLPushImage(msl_info,(Image *) NULL);
3312 if (attributes == (const xmlChar **) NULL)
3314 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3316 keyword=(const char *) attributes[i++];
3317 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3318 msl_info->attributes[n],(const char *) attributes[i]));
3324 if (LocaleCompare(keyword,"color") == 0)
3329 (void) CopyMagickString(msl_info->image_info[n]->filename,
3330 "xc:",MaxTextExtent);
3331 (void) ConcatenateMagickString(msl_info->image_info[n]->
3332 filename,value,MaxTextExtent);
3333 next_image=ReadImage(msl_info->image_info[n],&exception);
3334 CatchException(&exception);
3335 if (next_image == (Image *) NULL)
3337 if (msl_info->image[n] == (Image *) NULL)
3338 msl_info->image[n]=next_image;
3345 Link image into image list.
3347 p=msl_info->image[n];
3348 while (p->next != (Image *) NULL)
3349 p=GetNextImageInList(p);
3350 next_image->previous=p;
3355 (void) SetMSLAttributes(msl_info,keyword,value);
3360 (void) SetMSLAttributes(msl_info,keyword,value);
3367 if (LocaleCompare((const char *) tag,"implode") == 0)
3375 if (msl_info->image[n] == (Image *) NULL)
3377 ThrowMSLException(OptionError,"NoImagesDefined",
3378 (const char *) tag);
3381 if (attributes != (const xmlChar **) NULL)
3382 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3384 keyword=(const char *) attributes[i++];
3385 attribute=InterpretImageProperties(msl_info->image_info[n],
3386 msl_info->attributes[n],(const char *) attributes[i]);
3387 CloneString(&value,attribute);
3393 if (LocaleCompare(keyword,"amount") == 0)
3395 geometry_info.rho=StringToDouble(value);
3398 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3405 if (LocaleCompare(keyword,"geometry") == 0)
3407 flags=ParseGeometry(value,&geometry_info);
3408 if ((flags & SigmaValue) == 0)
3409 geometry_info.sigma=1.0;
3412 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3418 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3424 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3425 &msl_info->image[n]->exception);
3426 if (implode_image == (Image *) NULL)
3428 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3429 msl_info->image[n]=implode_image;
3432 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3437 if (LocaleCompare((const char *) tag,"label") == 0)
3439 if (LocaleCompare((const char *) tag, "level") == 0)
3442 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3444 if (msl_info->image[n] == (Image *) NULL)
3446 ThrowMSLException(OptionError,"NoImagesDefined",
3447 (const char *) tag);
3450 if (attributes == (const xmlChar **) NULL)
3452 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3454 keyword=(const char *) attributes[i++];
3455 CloneString(&value,(const char *) attributes[i]);
3456 (void) CopyMagickString(key,value,MaxTextExtent);
3462 if (LocaleCompare(keyword,"black") == 0)
3464 levelBlack = StringToDouble( value );
3467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3473 if (LocaleCompare(keyword,"gamma") == 0)
3475 levelGamma = StringToDouble( value );
3478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3484 if (LocaleCompare(keyword,"white") == 0)
3486 levelWhite = StringToDouble( value );
3489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3494 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3502 char level[MaxTextExtent + 1];
3503 (void) FormatMagickString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3504 levelBlack,levelGamma,levelWhite);
3505 LevelImage ( msl_info->image[n], level );
3513 if (LocaleCompare((const char *) tag,"magnify") == 0)
3521 if (msl_info->image[n] == (Image *) NULL)
3523 ThrowMSLException(OptionError,"NoImagesDefined",
3524 (const char *) tag);
3527 if (attributes != (const xmlChar **) NULL)
3528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3530 keyword=(const char *) attributes[i++];
3531 attribute=InterpretImageProperties(msl_info->image_info[n],
3532 msl_info->attributes[n],(const char *) attributes[i]);
3533 CloneString(&value,attribute);
3534 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3536 magnify_image=MagnifyImage(msl_info->image[n],
3537 &msl_info->image[n]->exception);
3538 if (magnify_image == (Image *) NULL)
3540 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3541 msl_info->image[n]=magnify_image;
3544 if (LocaleCompare((const char *) tag,"map") == 0)
3558 if (msl_info->image[n] == (Image *) NULL)
3560 ThrowMSLException(OptionError,"NoImagesDefined",
3561 (const char *) tag);
3564 affinity_image=NewImageList();
3566 if (attributes != (const xmlChar **) NULL)
3567 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3569 keyword=(const char *) attributes[i++];
3570 attribute=InterpretImageProperties(msl_info->image_info[n],
3571 msl_info->attributes[n],(const char *) attributes[i]);
3572 CloneString(&value,attribute);
3578 if (LocaleCompare(keyword,"dither") == 0)
3580 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
3583 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3585 dither=(MagickBooleanType) option;
3588 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3595 if (LocaleCompare(keyword,"image") == 0)
3596 for (j=0; j < msl_info->n; j++)
3601 attribute=GetImageProperty(msl_info->attributes[j],"id");
3602 if ((attribute != (const char *) NULL) &&
3603 (LocaleCompare(attribute,value) == 0))
3605 affinity_image=CloneImage(msl_info->image[j],0,0,
3606 MagickFalse,&exception);
3614 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3620 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3621 quantize_info->dither=dither;
3622 (void) RemapImages(quantize_info,msl_info->image[n],
3624 quantize_info=DestroyQuantizeInfo(quantize_info);
3625 affinity_image=DestroyImage(affinity_image);
3628 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3640 Matte floodfill image.
3643 if (msl_info->image[n] == (Image *) NULL)
3645 ThrowMSLException(OptionError,"NoImagesDefined",
3646 (const char *) tag);
3649 SetGeometry(msl_info->image[n],&geometry);
3650 paint_method=FloodfillMethod;
3651 if (attributes != (const xmlChar **) NULL)
3652 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3654 keyword=(const char *) attributes[i++];
3655 attribute=InterpretImageProperties(msl_info->image_info[n],
3656 msl_info->attributes[n],(const char *) attributes[i]);
3657 CloneString(&value,attribute);
3663 if (LocaleCompare(keyword,"bordercolor") == 0)
3665 (void) QueryMagickColor(value,&target,&exception);
3666 paint_method=FillToBorderMethod;
3669 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3676 if (LocaleCompare(keyword,"fuzz") == 0)
3678 msl_info->image[n]->fuzz=StringToDouble(value);
3681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3688 if (LocaleCompare(keyword,"geometry") == 0)
3690 flags=ParsePageGeometry(msl_info->image[n],value,
3691 &geometry,&exception);
3692 if ((flags & HeightValue) == 0)
3693 geometry.height=geometry.width;
3694 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3695 geometry.x,geometry.y,&target,&exception);
3698 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3705 if (LocaleCompare(keyword,"opacity") == 0)
3707 opacity=StringToDouble(value);
3710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3717 if (LocaleCompare(keyword,"x") == 0)
3719 geometry.x=StringToLong(value);
3720 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3721 geometry.x,geometry.y,&target,&exception);
3724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3731 if (LocaleCompare(keyword,"y") == 0)
3733 geometry.y=StringToLong(value);
3734 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3735 geometry.x,geometry.y,&target,&exception);
3738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3750 draw_info=CloneDrawInfo(msl_info->image_info[n],
3751 msl_info->draw_info[n]);
3752 draw_info->fill.opacity=ClampToQuantum(opacity);
3753 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3754 draw_info,&target,geometry.x,geometry.y,
3755 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3756 draw_info=DestroyDrawInfo(draw_info);
3759 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3765 Median-filter image.
3767 if (msl_info->image[n] == (Image *) NULL)
3769 ThrowMSLException(OptionError,"NoImagesDefined",
3770 (const char *) tag);
3773 if (attributes != (const xmlChar **) NULL)
3774 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3776 keyword=(const char *) attributes[i++];
3777 attribute=InterpretImageProperties(msl_info->image_info[n],
3778 msl_info->attributes[n],(const char *) attributes[i]);
3779 CloneString(&value,attribute);
3785 if (LocaleCompare(keyword,"geometry") == 0)
3787 flags=ParseGeometry(value,&geometry_info);
3788 if ((flags & SigmaValue) == 0)
3789 geometry_info.sigma=1.0;
3792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3799 if (LocaleCompare(keyword,"radius") == 0)
3801 geometry_info.rho=StringToDouble(value);
3804 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3816 median_image=MedianFilterImage(msl_info->image[n],geometry_info.rho,
3817 &msl_info->image[n]->exception);
3818 if (median_image == (Image *) NULL)
3820 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3821 msl_info->image[n]=median_image;
3824 if (LocaleCompare((const char *) tag,"minify") == 0)
3832 if (msl_info->image[n] == (Image *) NULL)
3834 ThrowMSLException(OptionError,"NoImagesDefined",
3835 (const char *) tag);
3838 if (attributes != (const xmlChar **) NULL)
3839 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3841 keyword=(const char *) attributes[i++];
3842 attribute=InterpretImageProperties(msl_info->image_info[n],
3843 msl_info->attributes[n],(const char *) attributes[i]);
3844 CloneString(&value,attribute);
3845 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3847 minify_image=MinifyImage(msl_info->image[n],
3848 &msl_info->image[n]->exception);
3849 if (minify_image == (Image *) NULL)
3851 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3852 msl_info->image[n]=minify_image;
3855 if (LocaleCompare((const char *) tag,"msl") == 0 )
3857 if (LocaleCompare((const char *) tag,"modulate") == 0)
3860 modulate[MaxTextExtent];
3865 if (msl_info->image[n] == (Image *) NULL)
3867 ThrowMSLException(OptionError,"NoImagesDefined",
3868 (const char *) tag);
3871 geometry_info.rho=100.0;
3872 geometry_info.sigma=100.0;
3873 geometry_info.xi=100.0;
3874 if (attributes != (const xmlChar **) NULL)
3875 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3877 keyword=(const char *) attributes[i++];
3878 attribute=InterpretImageProperties(msl_info->image_info[n],
3879 msl_info->attributes[n],(const char *) attributes[i]);
3880 CloneString(&value,attribute);
3886 if (LocaleCompare(keyword,"blackness") == 0)
3888 geometry_info.rho=StringToDouble(value);
3891 if (LocaleCompare(keyword,"brightness") == 0)
3893 geometry_info.rho=StringToDouble(value);
3896 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3903 if (LocaleCompare(keyword,"factor") == 0)
3905 flags=ParseGeometry(value,&geometry_info);
3908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3915 if (LocaleCompare(keyword,"hue") == 0)
3917 geometry_info.xi=StringToDouble(value);
3920 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3927 if (LocaleCompare(keyword,"lightness") == 0)
3929 geometry_info.rho=StringToDouble(value);
3932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3939 if (LocaleCompare(keyword,"saturation") == 0)
3941 geometry_info.sigma=StringToDouble(value);
3944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3951 if (LocaleCompare(keyword,"whiteness") == 0)
3953 geometry_info.sigma=StringToDouble(value);
3956 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3962 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3968 (void) FormatMagickString(modulate,MaxTextExtent,"%g,%g,%g",
3969 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3970 (void) ModulateImage(msl_info->image[n],modulate);
3973 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3978 if (LocaleCompare((const char *) tag,"negate") == 0)
3986 if (msl_info->image[n] == (Image *) NULL)
3988 ThrowMSLException(OptionError,"NoImagesDefined",
3989 (const char *) tag);
3993 if (attributes != (const xmlChar **) NULL)
3994 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3996 keyword=(const char *) attributes[i++];
3997 attribute=InterpretImageProperties(msl_info->image_info[n],
3998 msl_info->attributes[n],(const char *) attributes[i]);
3999 CloneString(&value,attribute);
4005 if (LocaleCompare(keyword,"channel") == 0)
4007 option=ParseChannelOption(value);
4009 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4011 channel=(ChannelType) option;
4014 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4021 if (LocaleCompare(keyword,"gray") == 0)
4023 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4026 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4028 gray=(MagickBooleanType) option;
4031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4043 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4046 if (LocaleCompare((const char *) tag,"normalize") == 0)
4051 if (msl_info->image[n] == (Image *) NULL)
4053 ThrowMSLException(OptionError,"NoImagesDefined",
4054 (const char *) tag);
4057 if (attributes != (const xmlChar **) NULL)
4058 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4060 keyword=(const char *) attributes[i++];
4061 attribute=InterpretImageProperties(msl_info->image_info[n],
4062 msl_info->attributes[n],(const char *) attributes[i]);
4063 CloneString(&value,attribute);
4069 if (LocaleCompare(keyword,"channel") == 0)
4071 option=ParseChannelOption(value);
4073 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4075 channel=(ChannelType) option;
4078 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4084 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4090 (void) NormalizeImageChannel(msl_info->image[n],channel);
4093 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4098 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4106 if (msl_info->image[n] == (Image *) NULL)
4108 ThrowMSLException(OptionError,"NoImagesDefined",
4109 (const char *) tag);
4112 if (attributes != (const xmlChar **) NULL)
4113 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4115 keyword=(const char *) attributes[i++];
4116 attribute=InterpretImageProperties(msl_info->image_info[n],
4117 msl_info->attributes[n],(const char *) attributes[i]);
4118 CloneString(&value,attribute);
4124 if (LocaleCompare(keyword,"geometry") == 0)
4126 flags=ParseGeometry(value,&geometry_info);
4127 if ((flags & SigmaValue) == 0)
4128 geometry_info.sigma=1.0;
4131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4138 if (LocaleCompare(keyword,"radius") == 0)
4140 geometry_info.rho=StringToDouble(value);
4143 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4155 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4156 &msl_info->image[n]->exception);
4157 if (paint_image == (Image *) NULL)
4159 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4160 msl_info->image[n]=paint_image;
4163 if (LocaleCompare((const char *) tag,"opaque") == 0)
4172 if (msl_info->image[n] == (Image *) NULL)
4174 ThrowMSLException(OptionError,"NoImagesDefined",
4175 (const char *) tag);
4178 (void) QueryMagickColor("none",&target,&exception);
4179 (void) QueryMagickColor("none",&fill_color,&exception);
4180 if (attributes != (const xmlChar **) NULL)
4181 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4183 keyword=(const char *) attributes[i++];
4184 attribute=InterpretImageProperties(msl_info->image_info[n],
4185 msl_info->attributes[n],(const char *) attributes[i]);
4186 CloneString(&value,attribute);
4192 if (LocaleCompare(keyword,"channel") == 0)
4194 option=ParseChannelOption(value);
4196 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4198 channel=(ChannelType) option;
4201 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4208 if (LocaleCompare(keyword,"fill") == 0)
4210 (void) QueryMagickColor(value,&fill_color,&exception);
4213 if (LocaleCompare(keyword,"fuzz") == 0)
4215 msl_info->image[n]->fuzz=StringToDouble(value);
4218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4224 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4230 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4231 &target,&fill_color,MagickFalse);
4234 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4239 if (LocaleCompare((const char *) tag,"print") == 0)
4241 if (attributes == (const xmlChar **) NULL)
4243 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4245 keyword=(const char *) attributes[i++];
4246 attribute=InterpretImageProperties(msl_info->image_info[n],
4247 msl_info->attributes[n],(const char *) attributes[i]);
4248 CloneString(&value,attribute);
4254 if (LocaleCompare(keyword,"output") == 0)
4256 (void) fprintf(stdout,"%s",value);
4259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4264 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4271 if (LocaleCompare((const char *) tag, "profile") == 0)
4273 if (msl_info->image[n] == (Image *) NULL)
4275 ThrowMSLException(OptionError,"NoImagesDefined",
4276 (const char *) tag);
4279 if (attributes == (const xmlChar **) NULL)
4281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4295 keyword=(const char *) attributes[i++];
4296 attribute=InterpretImageProperties(msl_info->image_info[n],
4297 msl_info->attributes[n],(const char *) attributes[i]);
4298 CloneString(&value,attribute);
4299 if (*keyword == '+')
4302 Remove a profile from the image.
4304 (void) ProfileImage(msl_info->image[n],keyword,
4305 (const unsigned char *) NULL,0,MagickTrue);
4309 Associate a profile with the image.
4311 profile_info=CloneImageInfo(msl_info->image_info[n]);
4312 profile=GetImageProfile(msl_info->image[n],"iptc");
4313 if (profile != (StringInfo *) NULL)
4314 profile_info->profile=(void *) CloneStringInfo(profile);
4315 profile_image=GetImageCache(profile_info,keyword,&exception);
4316 profile_info=DestroyImageInfo(profile_info);
4317 if (profile_image == (Image *) NULL)
4320 name[MaxTextExtent],
4321 filename[MaxTextExtent];
4329 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4330 (void) CopyMagickString(name,keyword,MaxTextExtent);
4331 for (p=filename; *p != '\0'; p++)
4332 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4333 (IsPathAccessible(keyword) == MagickFalse))
4339 Look for profile name (e.g. name:profile).
4341 (void) CopyMagickString(name,filename,(size_t)
4343 for (q=filename; *q != '\0'; q++)
4347 profile=FileToStringInfo(filename,~0UL,&exception);
4348 if (profile != (StringInfo *) NULL)
4350 (void) ProfileImage(msl_info->image[n],name,
4351 GetStringInfoDatum(profile),(size_t)
4352 GetStringInfoLength(profile),MagickFalse);
4353 profile=DestroyStringInfo(profile);
4357 ResetImageProfileIterator(profile_image);
4358 name=GetNextImageProfile(profile_image);
4359 while (name != (const char *) NULL)
4361 profile=GetImageProfile(profile_image,name);
4362 if (profile != (StringInfo *) NULL)
4363 (void) ProfileImage(msl_info->image[n],name,
4364 GetStringInfoDatum(profile),(size_t)
4365 GetStringInfoLength(profile),MagickFalse);
4366 name=GetNextImageProfile(profile_image);
4368 profile_image=DestroyImage(profile_image);
4372 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4377 if (LocaleCompare((const char *) tag,"quantize") == 0)
4385 if (msl_info->image[n] == (Image *) NULL)
4387 ThrowMSLException(OptionError,"NoImagesDefined",
4388 (const char *) tag);
4391 GetQuantizeInfo(&quantize_info);
4392 if (attributes != (const xmlChar **) NULL)
4393 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4395 keyword=(const char *) attributes[i++];
4396 attribute=InterpretImageProperties(msl_info->image_info[n],
4397 msl_info->attributes[n],(const char *) attributes[i]);
4398 CloneString(&value,attribute);
4404 if (LocaleCompare(keyword,"colors") == 0)
4406 quantize_info.number_colors=StringToLong(value);
4409 if (LocaleCompare(keyword,"colorspace") == 0)
4411 option=ParseMagickOption(MagickColorspaceOptions,
4414 ThrowMSLException(OptionError,
4415 "UnrecognizedColorspaceType",value);
4416 quantize_info.colorspace=(ColorspaceType) option;
4419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4426 if (LocaleCompare(keyword,"dither") == 0)
4428 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4431 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4433 quantize_info.dither=(MagickBooleanType) option;
4436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4443 if (LocaleCompare(keyword,"measure") == 0)
4445 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4448 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4450 quantize_info.measure_error=(MagickBooleanType) option;
4453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4460 if (LocaleCompare(keyword,"treedepth") == 0)
4462 quantize_info.tree_depth=StringToLong(value);
4465 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4471 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4477 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4480 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4483 text[MaxTextExtent];
4494 draw_info=CloneDrawInfo(msl_info->image_info[n],
4495 msl_info->draw_info[n]);
4497 current=draw_info->affine;
4498 GetAffineMatrix(&affine);
4499 if (attributes != (const xmlChar **) NULL)
4500 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4502 keyword=(const char *) attributes[i++];
4503 attribute=InterpretImageProperties(msl_info->image_info[n],
4504 msl_info->attributes[n],(const char *) attributes[i]);
4505 CloneString(&value,attribute);
4511 if (LocaleCompare(keyword,"affine") == 0)
4517 draw_info->affine.sx=strtod(p,&p);
4520 draw_info->affine.rx=strtod(p,&p);
4523 draw_info->affine.ry=strtod(p,&p);
4526 draw_info->affine.sy=strtod(p,&p);
4529 draw_info->affine.tx=strtod(p,&p);
4532 draw_info->affine.ty=strtod(p,&p);
4535 if (LocaleCompare(keyword,"align") == 0)
4537 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
4540 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4542 draw_info->align=(AlignType) option;
4545 if (LocaleCompare(keyword,"antialias") == 0)
4547 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4550 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4552 draw_info->stroke_antialias=(MagickBooleanType) option;
4553 draw_info->text_antialias=(MagickBooleanType) option;
4556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4563 if (LocaleCompare(keyword,"density") == 0)
4565 CloneString(&draw_info->density,value);
4568 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4575 if (LocaleCompare(keyword,"encoding") == 0)
4577 CloneString(&draw_info->encoding,value);
4580 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4587 if (LocaleCompare(keyword, "fill") == 0)
4589 (void) QueryColorDatabase(value,&draw_info->fill,
4593 if (LocaleCompare(keyword,"family") == 0)
4595 CloneString(&draw_info->family,value);
4598 if (LocaleCompare(keyword,"font") == 0)
4600 CloneString(&draw_info->font,value);
4603 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4610 if (LocaleCompare(keyword,"geometry") == 0)
4612 flags=ParsePageGeometry(msl_info->image[n],value,
4613 &geometry,&exception);
4614 if ((flags & HeightValue) == 0)
4615 geometry.height=geometry.width;
4618 if (LocaleCompare(keyword,"gravity") == 0)
4620 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
4623 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4625 draw_info->gravity=(GravityType) option;
4628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4635 if (LocaleCompare(keyword,"pointsize") == 0)
4637 draw_info->pointsize=StringToDouble(value);
4640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4647 if (LocaleCompare(keyword,"rotate") == 0)
4649 angle=StringToDouble(value);
4650 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4651 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4652 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4653 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4663 if (LocaleCompare(keyword,"scale") == 0)
4665 flags=ParseGeometry(value,&geometry_info);
4666 if ((flags & SigmaValue) == 0)
4667 geometry_info.sigma=1.0;
4668 affine.sx=geometry_info.rho;
4669 affine.sy=geometry_info.sigma;
4672 if (LocaleCompare(keyword,"skewX") == 0)
4674 angle=StringToDouble(value);
4675 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4678 if (LocaleCompare(keyword,"skewY") == 0)
4680 angle=StringToDouble(value);
4681 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4684 if (LocaleCompare(keyword,"stretch") == 0)
4686 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
4689 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4691 draw_info->stretch=(StretchType) option;
4694 if (LocaleCompare(keyword, "stroke") == 0)
4696 (void) QueryColorDatabase(value,&draw_info->stroke,
4700 if (LocaleCompare(keyword,"strokewidth") == 0)
4702 draw_info->stroke_width=StringToLong(value);
4705 if (LocaleCompare(keyword,"style") == 0)
4707 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
4710 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4712 draw_info->style=(StyleType) option;
4715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4722 if (LocaleCompare(keyword,"text") == 0)
4724 CloneString(&draw_info->text,value);
4727 if (LocaleCompare(keyword,"translate") == 0)
4729 flags=ParseGeometry(value,&geometry_info);
4730 if ((flags & SigmaValue) == 0)
4731 geometry_info.sigma=1.0;
4732 affine.tx=geometry_info.rho;
4733 affine.ty=geometry_info.sigma;
4736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4743 if (LocaleCompare(keyword, "undercolor") == 0)
4745 (void) QueryColorDatabase(value,&draw_info->undercolor,
4749 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4756 if (LocaleCompare(keyword,"weight") == 0)
4758 draw_info->weight=StringToLong(value);
4761 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4768 if (LocaleCompare(keyword,"x") == 0)
4770 geometry.x=StringToLong(value);
4773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4780 if (LocaleCompare(keyword,"y") == 0)
4782 geometry.y=StringToLong(value);
4785 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4797 (void) FormatMagickString(text,MaxTextExtent,
4798 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4799 geometry.height,(double) geometry.x,(double) geometry.y);
4800 CloneString(&draw_info->geometry,text);
4801 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4802 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4803 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4804 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4805 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4807 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4809 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4810 if (status != MagickFalse)
4815 image=msl_info->attributes[n];
4816 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4817 "%g",metrics.pixels_per_em.x);
4818 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4819 "%g",metrics.pixels_per_em.y);
4820 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4822 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4824 FormatImageProperty(image,"msl:font-metrics.width","%g",
4826 FormatImageProperty(image,"msl:font-metrics.height","%g",
4828 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4829 metrics.max_advance);
4830 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4832 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4834 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4836 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4838 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4840 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4843 draw_info=DestroyDrawInfo(draw_info);
4846 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4851 if (LocaleCompare((const char *) tag,"raise") == 0)
4859 if (msl_info->image[n] == (Image *) NULL)
4861 ThrowMSLException(OptionError,"NoImagesDefined",
4862 (const char *) tag);
4866 SetGeometry(msl_info->image[n],&geometry);
4867 if (attributes != (const xmlChar **) NULL)
4868 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4870 keyword=(const char *) attributes[i++];
4871 attribute=InterpretImageProperties(msl_info->image_info[n],
4872 msl_info->attributes[n],(const char *) attributes[i]);
4873 CloneString(&value,attribute);
4879 if (LocaleCompare(keyword,"geometry") == 0)
4881 flags=ParsePageGeometry(msl_info->image[n],value,
4882 &geometry,&exception);
4883 if ((flags & HeightValue) == 0)
4884 geometry.height=geometry.width;
4887 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4894 if (LocaleCompare(keyword,"height") == 0)
4896 geometry.height=StringToLong(value);
4899 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4906 if (LocaleCompare(keyword,"raise") == 0)
4908 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4911 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4913 raise=(MagickBooleanType) option;
4916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4923 if (LocaleCompare(keyword,"width") == 0)
4925 geometry.width=StringToLong(value);
4928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4934 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4940 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4943 if (LocaleCompare((const char *) tag,"read") == 0)
4945 if (attributes == (const xmlChar **) NULL)
4947 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4949 keyword=(const char *) attributes[i++];
4950 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4951 msl_info->attributes[n],(const char *) attributes[i]));
4957 if (LocaleCompare(keyword,"filename") == 0)
4962 (void) CopyMagickString(msl_info->image_info[n]->filename,
4963 value,MaxTextExtent);
4964 image=ReadImage(msl_info->image_info[n],&exception);
4965 CatchException(&exception);
4966 if (image == (Image *) NULL)
4968 AppendImageToList(&msl_info->image[n],image);
4971 (void) SetMSLAttributes(msl_info,keyword,value);
4976 (void) SetMSLAttributes(msl_info,keyword,value);
4983 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4991 if (msl_info->image[n] == (Image *) NULL)
4993 ThrowMSLException(OptionError,"NoImagesDefined",
4994 (const char *) tag);
4997 if (attributes != (const xmlChar **) NULL)
4998 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5000 keyword=(const char *) attributes[i++];
5001 attribute=InterpretImageProperties(msl_info->image_info[n],
5002 msl_info->attributes[n],(const char *) attributes[i]);
5003 CloneString(&value,attribute);
5009 if (LocaleCompare(keyword,"geometry") == 0)
5011 flags=ParseGeometry(value,&geometry_info);
5012 if ((flags & SigmaValue) == 0)
5013 geometry_info.sigma=1.0;
5016 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5023 if (LocaleCompare(keyword,"radius") == 0)
5025 geometry_info.rho=StringToDouble(value);
5028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5040 paint_image=ReduceNoiseImage(msl_info->image[n],geometry_info.rho,
5041 &msl_info->image[n]->exception);
5042 if (paint_image == (Image *) NULL)
5044 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5045 msl_info->image[n]=paint_image;
5048 else if (LocaleCompare((const char *) tag,"repage") == 0)
5050 /* init the values */
5051 width=msl_info->image[n]->page.width;
5052 height=msl_info->image[n]->page.height;
5053 x=msl_info->image[n]->page.x;
5054 y=msl_info->image[n]->page.y;
5056 if (msl_info->image[n] == (Image *) NULL)
5058 ThrowMSLException(OptionError,"NoImagesDefined",
5059 (const char *) tag);
5062 if (attributes == (const xmlChar **) NULL)
5064 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5066 keyword=(const char *) attributes[i++];
5067 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5068 msl_info->attributes[n],(const char *) attributes[i]));
5074 if (LocaleCompare(keyword,"geometry") == 0)
5082 flags=ParseAbsoluteGeometry(value,&geometry);
5083 if ((flags & WidthValue) != 0)
5085 if ((flags & HeightValue) == 0)
5086 geometry.height=geometry.width;
5087 width=geometry.width;
5088 height=geometry.height;
5090 if ((flags & AspectValue) != 0)
5092 if ((flags & XValue) != 0)
5094 if ((flags & YValue) != 0)
5099 if ((flags & XValue) != 0)
5102 if ((width == 0) && (geometry.x > 0))
5103 width=msl_info->image[n]->columns+geometry.x;
5105 if ((flags & YValue) != 0)
5108 if ((height == 0) && (geometry.y > 0))
5109 height=msl_info->image[n]->rows+geometry.y;
5114 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5120 if (LocaleCompare(keyword,"height") == 0)
5122 height = StringToLong( value );
5125 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5131 if (LocaleCompare(keyword,"width") == 0)
5133 width = StringToLong( value );
5136 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5142 if (LocaleCompare(keyword,"x") == 0)
5144 x = StringToLong( value );
5147 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5153 if (LocaleCompare(keyword,"y") == 0)
5155 y = StringToLong( value );
5158 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5163 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5169 msl_info->image[n]->page.width=width;
5170 msl_info->image[n]->page.height=height;
5171 msl_info->image[n]->page.x=x;
5172 msl_info->image[n]->page.y=y;
5175 else if (LocaleCompare((const char *) tag,"resample") == 0)
5181 if (msl_info->image[n] == (Image *) NULL)
5183 ThrowMSLException(OptionError,"NoImagesDefined",
5184 (const char *) tag);
5187 if (attributes == (const xmlChar **) NULL)
5189 x_resolution=DefaultResolution;
5190 y_resolution=DefaultResolution;
5191 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5193 keyword=(const char *) attributes[i++];
5194 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5195 msl_info->attributes[n],(const char *) attributes[i]));
5200 if (LocaleCompare(keyword,"blur") == 0)
5202 msl_info->image[n]->blur=StringToDouble(value);
5205 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5211 if (LocaleCompare(keyword,"geometry") == 0)
5216 flags=ParseGeometry(value,&geometry_info);
5217 if ((flags & SigmaValue) == 0)
5218 geometry_info.sigma*=geometry_info.rho;
5219 x_resolution=geometry_info.rho;
5220 y_resolution=geometry_info.sigma;
5223 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5229 if (LocaleCompare(keyword,"x-resolution") == 0)
5231 x_resolution=StringToDouble(value);
5234 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5240 if (LocaleCompare(keyword,"y-resolution") == 0)
5242 y_resolution=StringToDouble(value);
5245 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5250 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5266 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5268 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5269 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5270 msl_info->image[n]->x_resolution))+0.5);
5271 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5272 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5273 msl_info->image[n]->y_resolution))+0.5);
5274 resample_image=ResizeImage(msl_info->image[n],width,height,
5275 msl_info->image[n]->filter,msl_info->image[n]->blur,
5276 &msl_info->image[n]->exception);
5277 if (resample_image == (Image *) NULL)
5279 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5280 msl_info->image[n]=resample_image;
5284 if (LocaleCompare((const char *) tag,"resize") == 0)
5298 if (msl_info->image[n] == (Image *) NULL)
5300 ThrowMSLException(OptionError,"NoImagesDefined",
5301 (const char *) tag);
5304 filter=UndefinedFilter;
5306 if (attributes != (const xmlChar **) NULL)
5307 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5309 keyword=(const char *) attributes[i++];
5310 attribute=InterpretImageProperties(msl_info->image_info[n],
5311 msl_info->attributes[n],(const char *) attributes[i]);
5312 CloneString(&value,attribute);
5318 if (LocaleCompare(keyword,"filter") == 0)
5320 option=ParseMagickOption(MagickFilterOptions,MagickFalse,
5323 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5325 filter=(FilterTypes) option;
5328 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5335 if (LocaleCompare(keyword,"geometry") == 0)
5337 flags=ParseRegionGeometry(msl_info->image[n],value,
5338 &geometry,&exception);
5341 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5348 if (LocaleCompare(keyword,"height") == 0)
5350 geometry.height=StringToUnsignedLong(value);
5353 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5360 if (LocaleCompare(keyword,"support") == 0)
5362 blur=StringToDouble(value);
5365 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5372 if (LocaleCompare(keyword,"width") == 0)
5374 geometry.width=StringToLong(value);
5377 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5383 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5389 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5390 geometry.height,filter,blur,&msl_info->image[n]->exception);
5391 if (resize_image == (Image *) NULL)
5393 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5394 msl_info->image[n]=resize_image;
5397 if (LocaleCompare((const char *) tag,"roll") == 0)
5405 if (msl_info->image[n] == (Image *) NULL)
5407 ThrowMSLException(OptionError,"NoImagesDefined",
5408 (const char *) tag);
5411 SetGeometry(msl_info->image[n],&geometry);
5412 if (attributes != (const xmlChar **) NULL)
5413 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5415 keyword=(const char *) attributes[i++];
5416 attribute=InterpretImageProperties(msl_info->image_info[n],
5417 msl_info->attributes[n],(const char *) attributes[i]);
5418 CloneString(&value,attribute);
5424 if (LocaleCompare(keyword,"geometry") == 0)
5426 flags=ParsePageGeometry(msl_info->image[n],value,
5427 &geometry,&exception);
5428 if ((flags & HeightValue) == 0)
5429 geometry.height=geometry.width;
5432 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5439 if (LocaleCompare(keyword,"x") == 0)
5441 geometry.x=StringToLong(value);
5444 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5451 if (LocaleCompare(keyword,"y") == 0)
5453 geometry.y=StringToLong(value);
5456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5468 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5469 &msl_info->image[n]->exception);
5470 if (roll_image == (Image *) NULL)
5472 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5473 msl_info->image[n]=roll_image;
5476 else if (LocaleCompare((const char *) tag,"roll") == 0)
5478 /* init the values */
5479 width=msl_info->image[n]->columns;
5480 height=msl_info->image[n]->rows;
5483 if (msl_info->image[n] == (Image *) NULL)
5485 ThrowMSLException(OptionError,"NoImagesDefined",
5486 (const char *) tag);
5489 if (attributes == (const xmlChar **) NULL)
5491 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5493 keyword=(const char *) attributes[i++];
5494 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5495 msl_info->attributes[n],(const char *) attributes[i]));
5501 if (LocaleCompare(keyword,"geometry") == 0)
5503 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5506 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5512 if (LocaleCompare(keyword,"x") == 0)
5514 x = StringToLong( value );
5517 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5523 if (LocaleCompare(keyword,"y") == 0)
5525 y = StringToLong( value );
5528 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5533 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5546 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5547 if (newImage == (Image *) NULL)
5549 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5550 msl_info->image[n]=newImage;
5555 if (LocaleCompare((const char *) tag,"rotate") == 0)
5563 if (msl_info->image[n] == (Image *) NULL)
5565 ThrowMSLException(OptionError,"NoImagesDefined",
5566 (const char *) tag);
5569 if (attributes != (const xmlChar **) NULL)
5570 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5572 keyword=(const char *) attributes[i++];
5573 attribute=InterpretImageProperties(msl_info->image_info[n],
5574 msl_info->attributes[n],(const char *) attributes[i]);
5575 CloneString(&value,attribute);
5581 if (LocaleCompare(keyword,"degrees") == 0)
5583 geometry_info.rho=StringToDouble(value);
5586 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5593 if (LocaleCompare(keyword,"geometry") == 0)
5595 flags=ParseGeometry(value,&geometry_info);
5596 if ((flags & SigmaValue) == 0)
5597 geometry_info.sigma=1.0;
5600 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5612 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5613 &msl_info->image[n]->exception);
5614 if (rotate_image == (Image *) NULL)
5616 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5617 msl_info->image[n]=rotate_image;
5620 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5622 /* init the values */
5625 if (msl_info->image[n] == (Image *) NULL)
5627 ThrowMSLException(OptionError,"NoImagesDefined",
5628 (const char *) tag);
5631 if (attributes == (const xmlChar **) NULL)
5633 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5635 keyword=(const char *) attributes[i++];
5636 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5637 msl_info->attributes[n],(const char *) attributes[i]));
5643 if (LocaleCompare(keyword,"degrees") == 0)
5645 degrees = StringToDouble( value );
5648 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5653 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5666 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5667 if (newImage == (Image *) NULL)
5669 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5670 msl_info->image[n]=newImage;
5675 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5680 if (LocaleCompare((const char *) tag,"sample") == 0)
5688 if (msl_info->image[n] == (Image *) NULL)
5690 ThrowMSLException(OptionError,"NoImagesDefined",
5691 (const char *) tag);
5694 if (attributes != (const xmlChar **) NULL)
5695 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5697 keyword=(const char *) attributes[i++];
5698 attribute=InterpretImageProperties(msl_info->image_info[n],
5699 msl_info->attributes[n],(const char *) attributes[i]);
5700 CloneString(&value,attribute);
5706 if (LocaleCompare(keyword,"geometry") == 0)
5708 flags=ParseRegionGeometry(msl_info->image[n],value,
5709 &geometry,&exception);
5712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5719 if (LocaleCompare(keyword,"height") == 0)
5721 geometry.height=StringToUnsignedLong(value);
5724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5731 if (LocaleCompare(keyword,"width") == 0)
5733 geometry.width=StringToLong(value);
5736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5748 sample_image=SampleImage(msl_info->image[n],geometry.width,
5749 geometry.height,&msl_info->image[n]->exception);
5750 if (sample_image == (Image *) NULL)
5752 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5753 msl_info->image[n]=sample_image;
5756 if (LocaleCompare((const char *) tag,"scale") == 0)
5764 if (msl_info->image[n] == (Image *) NULL)
5766 ThrowMSLException(OptionError,"NoImagesDefined",
5767 (const char *) tag);
5770 if (attributes != (const xmlChar **) NULL)
5771 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5773 keyword=(const char *) attributes[i++];
5774 attribute=InterpretImageProperties(msl_info->image_info[n],
5775 msl_info->attributes[n],(const char *) attributes[i]);
5776 CloneString(&value,attribute);
5782 if (LocaleCompare(keyword,"geometry") == 0)
5784 flags=ParseRegionGeometry(msl_info->image[n],value,
5785 &geometry,&exception);
5788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5795 if (LocaleCompare(keyword,"height") == 0)
5797 geometry.height=StringToUnsignedLong(value);
5800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5807 if (LocaleCompare(keyword,"width") == 0)
5809 geometry.width=StringToLong(value);
5812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5818 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5824 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5825 geometry.height,&msl_info->image[n]->exception);
5826 if (scale_image == (Image *) NULL)
5828 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5829 msl_info->image[n]=scale_image;
5832 if (LocaleCompare((const char *) tag,"segment") == 0)
5843 if (msl_info->image[n] == (Image *) NULL)
5845 ThrowMSLException(OptionError,"NoImagesDefined",
5846 (const char *) tag);
5849 geometry_info.rho=1.0;
5850 geometry_info.sigma=1.5;
5851 colorspace=RGBColorspace;
5852 verbose=MagickFalse;
5853 if (attributes != (const xmlChar **) NULL)
5854 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5856 keyword=(const char *) attributes[i++];
5857 attribute=InterpretImageProperties(msl_info->image_info[n],
5858 msl_info->attributes[n],(const char *) attributes[i]);
5859 CloneString(&value,attribute);
5865 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5867 geometry_info.rho=StringToDouble(value);
5870 if (LocaleCompare(keyword,"colorspace") == 0)
5872 option=ParseMagickOption(MagickColorspaceOptions,
5875 ThrowMSLException(OptionError,
5876 "UnrecognizedColorspaceType",value);
5877 colorspace=(ColorspaceType) option;
5880 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5887 if (LocaleCompare(keyword,"geometry") == 0)
5889 flags=ParseGeometry(value,&geometry_info);
5890 if ((flags & SigmaValue) == 0)
5891 geometry_info.sigma=1.5;
5894 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5901 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5903 geometry_info.sigma=StringToDouble(value);
5906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5918 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5919 geometry_info.rho,geometry_info.sigma);
5922 else if (LocaleCompare((const char *) tag, "set") == 0)
5924 if (msl_info->image[n] == (Image *) NULL)
5926 ThrowMSLException(OptionError,"NoImagesDefined",
5927 (const char *) tag);
5931 if (attributes == (const xmlChar **) NULL)
5933 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5935 keyword=(const char *) attributes[i++];
5936 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5937 msl_info->attributes[n],(const char *) attributes[i]));
5943 if (LocaleCompare(keyword,"clip-mask") == 0)
5945 for (j=0; j < msl_info->n; j++)
5950 property=GetImageProperty(msl_info->attributes[j],"id");
5951 if (LocaleCompare(property,value) == 0)
5953 SetImageMask(msl_info->image[n],msl_info->image[j]);
5959 if (LocaleCompare(keyword,"clip-path") == 0)
5961 for (j=0; j < msl_info->n; j++)
5966 property=GetImageProperty(msl_info->attributes[j],"id");
5967 if (LocaleCompare(property,value) == 0)
5969 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5975 if (LocaleCompare(keyword,"colorspace") == 0)
5980 colorspace=(ColorspaceType) ParseMagickOption(
5981 MagickColorspaceOptions,MagickFalse,keyword);
5983 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5985 (void) TransformImageColorspace(msl_info->image[n],
5986 (ColorspaceType) colorspace);
5989 (void) SetMSLAttributes(msl_info,keyword,value);
5995 if (LocaleCompare(keyword,"density") == 0)
5997 flags=ParseGeometry(value,&geometry_info);
5998 msl_info->image[n]->x_resolution=geometry_info.rho;
5999 msl_info->image[n]->y_resolution=geometry_info.sigma;
6000 if ((flags & SigmaValue) == 0)
6001 msl_info->image[n]->y_resolution=
6002 msl_info->image[n]->x_resolution;
6005 (void) SetMSLAttributes(msl_info,keyword,value);
6011 if (LocaleCompare(keyword, "opacity") == 0)
6013 ssize_t opac = OpaqueOpacity,
6014 len = (ssize_t) strlen( value );
6016 if (value[len-1] == '%') {
6018 (void) CopyMagickString(tmp,value,len);
6019 opac = StringToLong( tmp );
6020 opac = (int)(QuantumRange * ((float)opac/100));
6022 opac = StringToLong( value );
6023 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6026 (void) SetMSLAttributes(msl_info,keyword,value);
6032 if (LocaleCompare(keyword, "page") == 0)
6035 page[MaxTextExtent];
6046 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6047 image_option=GetImageOption(msl_info->image_info[n],"page");
6048 if (image_option != (const char *) NULL)
6049 flags=ParseAbsoluteGeometry(image_option,&geometry);
6050 flags=ParseAbsoluteGeometry(value,&geometry);
6051 (void) FormatMagickString(page,MaxTextExtent,"%.20gx%.20g",
6052 (double) geometry.width,(double) geometry.height);
6053 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6054 (void) FormatMagickString(page,MaxTextExtent,
6055 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6056 (double) geometry.height,(double) geometry.x,(double)
6058 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6059 msl_info->image_info[n]->page=GetPageGeometry(page);
6062 (void) SetMSLAttributes(msl_info,keyword,value);
6067 (void) SetMSLAttributes(msl_info,keyword,value);
6074 if (LocaleCompare((const char *) tag,"shade") == 0)
6085 if (msl_info->image[n] == (Image *) NULL)
6087 ThrowMSLException(OptionError,"NoImagesDefined",
6088 (const char *) tag);
6092 if (attributes != (const xmlChar **) NULL)
6093 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6095 keyword=(const char *) attributes[i++];
6096 attribute=InterpretImageProperties(msl_info->image_info[n],
6097 msl_info->attributes[n],(const char *) attributes[i]);
6098 CloneString(&value,attribute);
6104 if (LocaleCompare(keyword,"azimuth") == 0)
6106 geometry_info.rho=StringToDouble(value);
6109 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6116 if (LocaleCompare(keyword,"elevation") == 0)
6118 geometry_info.sigma=StringToDouble(value);
6121 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6128 if (LocaleCompare(keyword,"geometry") == 0)
6130 flags=ParseGeometry(value,&geometry_info);
6131 if ((flags & SigmaValue) == 0)
6132 geometry_info.sigma=1.0;
6135 if (LocaleCompare(keyword,"gray") == 0)
6137 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6140 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6142 gray=(MagickBooleanType) option;
6145 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6151 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6157 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6158 geometry_info.sigma,&msl_info->image[n]->exception);
6159 if (shade_image == (Image *) NULL)
6161 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6162 msl_info->image[n]=shade_image;
6165 if (LocaleCompare((const char *) tag,"shadow") == 0)
6173 if (msl_info->image[n] == (Image *) NULL)
6175 ThrowMSLException(OptionError,"NoImagesDefined",
6176 (const char *) tag);
6179 if (attributes != (const xmlChar **) NULL)
6180 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6182 keyword=(const char *) attributes[i++];
6183 attribute=InterpretImageProperties(msl_info->image_info[n],
6184 msl_info->attributes[n],(const char *) attributes[i]);
6185 CloneString(&value,attribute);
6191 if (LocaleCompare(keyword,"geometry") == 0)
6193 flags=ParseGeometry(value,&geometry_info);
6194 if ((flags & SigmaValue) == 0)
6195 geometry_info.sigma=1.0;
6198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6205 if (LocaleCompare(keyword,"opacity") == 0)
6207 geometry_info.rho=StringToLong(value);
6210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6217 if (LocaleCompare(keyword,"sigma") == 0)
6219 geometry_info.sigma=StringToLong(value);
6227 if (LocaleCompare(keyword,"x") == 0)
6229 geometry_info.xi=StringToDouble(value);
6232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6239 if (LocaleCompare(keyword,"y") == 0)
6241 geometry_info.psi=StringToLong(value);
6244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6250 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6256 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6257 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6258 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6259 if (shadow_image == (Image *) NULL)
6261 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6262 msl_info->image[n]=shadow_image;
6265 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6267 double radius = 0.0,
6270 if (msl_info->image[n] == (Image *) NULL)
6272 ThrowMSLException(OptionError,"NoImagesDefined",
6273 (const char *) tag);
6277 NOTE: sharpen can have no attributes, since we use all the defaults!
6279 if (attributes != (const xmlChar **) NULL)
6281 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6283 keyword=(const char *) attributes[i++];
6284 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6285 msl_info->attributes[n],(const char *) attributes[i]));
6291 if (LocaleCompare(keyword, "radius") == 0)
6293 radius = StringToDouble( value );
6296 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6302 if (LocaleCompare(keyword,"sigma") == 0)
6304 sigma = StringToLong( value );
6307 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6312 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6326 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6327 if (newImage == (Image *) NULL)
6329 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6330 msl_info->image[n]=newImage;
6334 else if (LocaleCompare((const char *) tag,"shave") == 0)
6336 /* init the values */
6340 if (msl_info->image[n] == (Image *) NULL)
6342 ThrowMSLException(OptionError,"NoImagesDefined",
6343 (const char *) tag);
6346 if (attributes == (const xmlChar **) NULL)
6348 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6350 keyword=(const char *) attributes[i++];
6351 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6352 msl_info->attributes[n],(const char *) attributes[i]));
6358 if (LocaleCompare(keyword,"geometry") == 0)
6360 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6363 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6369 if (LocaleCompare(keyword,"height") == 0)
6371 height = StringToLong( value );
6374 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6380 if (LocaleCompare(keyword,"width") == 0)
6382 width = StringToLong( value );
6385 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6390 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6405 rectInfo.height = height;
6406 rectInfo.width = width;
6411 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6412 &msl_info->image[n]->exception);
6413 if (newImage == (Image *) NULL)
6415 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6416 msl_info->image[n]=newImage;
6421 if (LocaleCompare((const char *) tag,"shear") == 0)
6429 if (msl_info->image[n] == (Image *) NULL)
6431 ThrowMSLException(OptionError,"NoImagesDefined",
6432 (const char *) tag);
6435 if (attributes != (const xmlChar **) NULL)
6436 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6438 keyword=(const char *) attributes[i++];
6439 attribute=InterpretImageProperties(msl_info->image_info[n],
6440 msl_info->attributes[n],(const char *) attributes[i]);
6441 CloneString(&value,attribute);
6447 if (LocaleCompare(keyword, "fill") == 0)
6449 (void) QueryColorDatabase(value,
6450 &msl_info->image[n]->background_color,&exception);
6453 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6460 if (LocaleCompare(keyword,"geometry") == 0)
6462 flags=ParseGeometry(value,&geometry_info);
6463 if ((flags & SigmaValue) == 0)
6464 geometry_info.sigma=1.0;
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6474 if (LocaleCompare(keyword,"x") == 0)
6476 geometry_info.rho=StringToDouble(value);
6479 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6486 if (LocaleCompare(keyword,"y") == 0)
6488 geometry_info.sigma=StringToLong(value);
6491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6497 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6503 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6504 geometry_info.sigma,&msl_info->image[n]->exception);
6505 if (shear_image == (Image *) NULL)
6507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6508 msl_info->image[n]=shear_image;
6511 if (LocaleCompare((const char *) tag,"signature") == 0)
6516 if (msl_info->image[n] == (Image *) NULL)
6518 ThrowMSLException(OptionError,"NoImagesDefined",
6519 (const char *) tag);
6522 if (attributes != (const xmlChar **) NULL)
6523 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6525 keyword=(const char *) attributes[i++];
6526 attribute=InterpretImageProperties(msl_info->image_info[n],
6527 msl_info->attributes[n],(const char *) attributes[i]);
6528 CloneString(&value,attribute);
6533 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6539 (void) SignatureImage(msl_info->image[n]);
6542 if (LocaleCompare((const char *) tag,"solarize") == 0)
6547 if (msl_info->image[n] == (Image *) NULL)
6549 ThrowMSLException(OptionError,"NoImagesDefined",
6550 (const char *) tag);
6553 geometry_info.rho=QuantumRange/2.0;
6554 if (attributes != (const xmlChar **) NULL)
6555 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6557 keyword=(const char *) attributes[i++];
6558 attribute=InterpretImageProperties(msl_info->image_info[n],
6559 msl_info->attributes[n],(const char *) attributes[i]);
6560 CloneString(&value,attribute);
6566 if (LocaleCompare(keyword,"geometry") == 0)
6568 flags=ParseGeometry(value,&geometry_info);
6571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6578 if (LocaleCompare(keyword,"threshold") == 0)
6580 geometry_info.rho=StringToDouble(value);
6583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6595 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6598 if (LocaleCompare((const char *) tag,"spread") == 0)
6606 if (msl_info->image[n] == (Image *) NULL)
6608 ThrowMSLException(OptionError,"NoImagesDefined",
6609 (const char *) tag);
6612 if (attributes != (const xmlChar **) NULL)
6613 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6615 keyword=(const char *) attributes[i++];
6616 attribute=InterpretImageProperties(msl_info->image_info[n],
6617 msl_info->attributes[n],(const char *) attributes[i]);
6618 CloneString(&value,attribute);
6624 if (LocaleCompare(keyword,"geometry") == 0)
6626 flags=ParseGeometry(value,&geometry_info);
6627 if ((flags & SigmaValue) == 0)
6628 geometry_info.sigma=1.0;
6631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6638 if (LocaleCompare(keyword,"radius") == 0)
6640 geometry_info.rho=StringToDouble(value);
6643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6649 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6655 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6656 &msl_info->image[n]->exception);
6657 if (spread_image == (Image *) NULL)
6659 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6660 msl_info->image[n]=spread_image;
6663 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6666 watermark = (Image*)NULL;
6668 if (msl_info->image[n] == (Image *) NULL)
6670 ThrowMSLException(OptionError,"NoImagesDefined",
6671 (const char *) tag);
6674 if (attributes == (const xmlChar **) NULL)
6676 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6678 keyword=(const char *) attributes[i++];
6679 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6680 msl_info->attributes[n],(const char *) attributes[i]));
6686 if (LocaleCompare(keyword,"image") == 0)
6688 for (j=0; j<msl_info->n;j++)
6691 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6692 if (theAttr && LocaleCompare(theAttr, value) == 0)
6694 watermark = msl_info->image[j];
6700 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6705 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6714 if ( watermark != (Image*) NULL )
6719 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6720 if (newImage == (Image *) NULL)
6722 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6723 msl_info->image[n]=newImage;
6726 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6728 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6731 stereoImage = (Image*)NULL;
6733 if (msl_info->image[n] == (Image *) NULL)
6735 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6738 if (attributes == (const xmlChar **) NULL)
6740 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6742 keyword=(const char *) attributes[i++];
6743 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6744 msl_info->attributes[n],(const char *) attributes[i]));
6750 if (LocaleCompare(keyword,"image") == 0)
6752 for (j=0; j<msl_info->n;j++)
6755 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6756 if (theAttr && LocaleCompare(theAttr, value) == 0)
6758 stereoImage = msl_info->image[j];
6764 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6769 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6778 if ( stereoImage != (Image*) NULL )
6783 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6784 if (newImage == (Image *) NULL)
6786 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6787 msl_info->image[n]=newImage;
6790 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6792 if (LocaleCompare((const char *) tag,"swap") == 0)
6803 if (msl_info->image[n] == (Image *) NULL)
6805 ThrowMSLException(OptionError,"NoImagesDefined",
6806 (const char *) tag);
6811 if (attributes != (const xmlChar **) NULL)
6812 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6814 keyword=(const char *) attributes[i++];
6815 attribute=InterpretImageProperties(msl_info->image_info[n],
6816 msl_info->attributes[n],(const char *) attributes[i]);
6817 CloneString(&value,attribute);
6823 if (LocaleCompare(keyword,"indexes") == 0)
6825 flags=ParseGeometry(value,&geometry_info);
6826 index=(ssize_t) geometry_info.rho;
6827 if ((flags & SigmaValue) == 0)
6828 swap_index=(ssize_t) geometry_info.sigma;
6831 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6846 p=GetImageFromList(msl_info->image[n],index);
6847 q=GetImageFromList(msl_info->image[n],swap_index);
6848 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6850 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6853 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6854 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6855 ReplaceImageInList(&q,swap);
6856 msl_info->image[n]=GetFirstImageInList(q);
6859 if (LocaleCompare((const char *) tag,"swirl") == 0)
6867 if (msl_info->image[n] == (Image *) NULL)
6869 ThrowMSLException(OptionError,"NoImagesDefined",
6870 (const char *) tag);
6873 if (attributes != (const xmlChar **) NULL)
6874 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6876 keyword=(const char *) attributes[i++];
6877 attribute=InterpretImageProperties(msl_info->image_info[n],
6878 msl_info->attributes[n],(const char *) attributes[i]);
6879 CloneString(&value,attribute);
6885 if (LocaleCompare(keyword,"degrees") == 0)
6887 geometry_info.rho=StringToDouble(value);
6890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6897 if (LocaleCompare(keyword,"geometry") == 0)
6899 flags=ParseGeometry(value,&geometry_info);
6900 if ((flags & SigmaValue) == 0)
6901 geometry_info.sigma=1.0;
6904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6916 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6917 &msl_info->image[n]->exception);
6918 if (swirl_image == (Image *) NULL)
6920 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6921 msl_info->image[n]=swirl_image;
6924 if (LocaleCompare((const char *) tag,"sync") == 0)
6929 if (msl_info->image[n] == (Image *) NULL)
6931 ThrowMSLException(OptionError,"NoImagesDefined",
6932 (const char *) tag);
6935 if (attributes != (const xmlChar **) NULL)
6936 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6938 keyword=(const char *) attributes[i++];
6939 attribute=InterpretImageProperties(msl_info->image_info[n],
6940 msl_info->attributes[n],(const char *) attributes[i]);
6941 CloneString(&value,attribute);
6946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6952 (void) SyncImage(msl_info->image[n]);
6955 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6960 if (LocaleCompare((const char *) tag,"map") == 0)
6968 if (msl_info->image[n] == (Image *) NULL)
6970 ThrowMSLException(OptionError,"NoImagesDefined",
6971 (const char *) tag);
6974 texture_image=NewImageList();
6975 if (attributes != (const xmlChar **) NULL)
6976 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6978 keyword=(const char *) attributes[i++];
6979 attribute=InterpretImageProperties(msl_info->image_info[n],
6980 msl_info->attributes[n],(const char *) attributes[i]);
6981 CloneString(&value,attribute);
6987 if (LocaleCompare(keyword,"image") == 0)
6988 for (j=0; j < msl_info->n; j++)
6993 attribute=GetImageProperty(msl_info->attributes[j],"id");
6994 if ((attribute != (const char *) NULL) &&
6995 (LocaleCompare(attribute,value) == 0))
6997 texture_image=CloneImage(msl_info->image[j],0,0,
6998 MagickFalse,&exception);
7006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7012 (void) TextureImage(msl_info->image[n],texture_image);
7013 texture_image=DestroyImage(texture_image);
7016 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7018 /* init the values */
7019 double threshold = 0;
7021 if (msl_info->image[n] == (Image *) NULL)
7023 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7026 if (attributes == (const xmlChar **) NULL)
7028 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7030 keyword=(const char *) attributes[i++];
7031 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7032 msl_info->attributes[n],(const char *) attributes[i]));
7038 if (LocaleCompare(keyword,"threshold") == 0)
7040 threshold = StringToDouble( value );
7043 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7048 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7058 BilevelImageChannel(msl_info->image[n],
7059 (ChannelType) ((ssize_t) (AllChannels &~ (ssize_t) OpacityChannel)),
7064 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7066 if (msl_info->image[n] == (Image *) NULL)
7068 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7071 if (attributes == (const xmlChar **) NULL)
7073 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7075 keyword=(const char *) attributes[i++];
7076 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7077 msl_info->attributes[n],(const char *) attributes[i]));
7083 if (LocaleCompare(keyword,"color") == 0)
7088 (void) QueryMagickColor(value,&target,&exception);
7089 (void) TransparentPaintImage(msl_info->image[n],&target,
7090 TransparentOpacity,MagickFalse);
7093 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7105 else if (LocaleCompare((const char *) tag, "trim") == 0)
7107 if (msl_info->image[n] == (Image *) NULL)
7109 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7113 /* no attributes here */
7115 /* process the image */
7122 /* all zeros on a crop == trim edges! */
7123 rectInfo.height = rectInfo.width = 0;
7124 rectInfo.x = rectInfo.y = 0;
7126 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7127 if (newImage == (Image *) NULL)
7129 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7130 msl_info->image[n]=newImage;
7134 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7139 if (LocaleCompare((const char *) tag,"write") == 0)
7141 if (msl_info->image[n] == (Image *) NULL)
7143 ThrowMSLException(OptionError,"NoImagesDefined",
7144 (const char *) tag);
7147 if (attributes == (const xmlChar **) NULL)
7149 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7151 keyword=(const char *) attributes[i++];
7152 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7153 msl_info->attributes[n],(const char *) attributes[i]));
7159 if (LocaleCompare(keyword,"filename") == 0)
7161 (void) CopyMagickString(msl_info->image[n]->filename,value,
7165 (void) SetMSLAttributes(msl_info,keyword,value);
7169 (void) SetMSLAttributes(msl_info,keyword,value);
7177 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7181 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7185 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7189 if ( value != NULL )
7190 value=DestroyString(value);
7191 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7194 static void MSLEndElement(void *context,const xmlChar *tag)
7203 Called when the end of an element has been detected.
7205 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7207 msl_info=(MSLInfo *) context;
7214 if (LocaleCompare((const char *) tag,"comment") == 0 )
7216 (void) DeleteImageProperty(msl_info->image[n],"comment");
7217 if (msl_info->content == (char *) NULL)
7219 StripString(msl_info->content);
7220 (void) SetImageProperty(msl_info->image[n],"comment",
7229 if (LocaleCompare((const char *) tag, "group") == 0 )
7231 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7233 ssize_t i = (ssize_t)
7234 (msl_info->group_info[msl_info->number_groups-1].numImages);
7237 if (msl_info->image[msl_info->n] != (Image *) NULL)
7238 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7239 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7240 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7244 msl_info->number_groups--;
7251 if (LocaleCompare((const char *) tag, "image") == 0)
7252 MSLPopImage(msl_info);
7258 if (LocaleCompare((const char *) tag,"label") == 0 )
7260 (void) DeleteImageProperty(msl_info->image[n],"label");
7261 if (msl_info->content == (char *) NULL)
7263 StripString(msl_info->content);
7264 (void) SetImageProperty(msl_info->image[n],"label",
7273 if (LocaleCompare((const char *) tag, "msl") == 0 )
7276 This our base element.
7277 at the moment we don't do anything special
7278 but someday we might!
7286 if (msl_info->content != (char *) NULL)
7287 msl_info->content=DestroyString(msl_info->content);
7290 static void MSLCharacters(void *context,const xmlChar *c,int length)
7302 Receiving some characters from the parser.
7304 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7305 " SAX.characters(%s,%d)",c,length);
7306 msl_info=(MSLInfo *) context;
7307 if (msl_info->content != (char *) NULL)
7308 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7309 strlen(msl_info->content)+length+MaxTextExtent,
7310 sizeof(*msl_info->content));
7313 msl_info->content=(char *) NULL;
7314 if (~length >= MaxTextExtent)
7315 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7316 sizeof(*msl_info->content));
7317 if (msl_info->content != (char *) NULL)
7318 *msl_info->content='\0';
7320 if (msl_info->content == (char *) NULL)
7322 p=msl_info->content+strlen(msl_info->content);
7323 for (i=0; i < length; i++)
7328 static void MSLReference(void *context,const xmlChar *name)
7337 Called when an entity reference is detected.
7339 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7340 " SAX.reference(%s)",name);
7341 msl_info=(MSLInfo *) context;
7342 parser=msl_info->parser;
7344 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7346 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7349 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7355 Receiving some ignorable whitespaces from the parser.
7357 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7358 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7359 msl_info=(MSLInfo *) context;
7362 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7363 const xmlChar *data)
7369 A processing instruction has been parsed.
7371 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7372 " SAX.processingInstruction(%s, %s)",
7374 msl_info=(MSLInfo *) context;
7377 static void MSLComment(void *context,const xmlChar *value)
7383 A comment has been parsed.
7385 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7386 " SAX.comment(%s)",value);
7387 msl_info=(MSLInfo *) context;
7390 static void MSLWarning(void *context,const char *format,...)
7394 reason[MaxTextExtent];
7403 Display and format a warning messages, gives file, line, position and
7406 va_start(operands,format);
7407 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7408 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7409 msl_info=(MSLInfo *) context;
7410 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7411 (void) vsprintf(reason,format,operands);
7413 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7415 message=GetExceptionMessage(errno);
7416 ThrowMSLException(CoderError,reason,message);
7417 message=DestroyString(message);
7421 static void MSLError(void *context,const char *format,...)
7424 reason[MaxTextExtent];
7433 Display and format a error formats, gives file, line, position and
7436 va_start(operands,format);
7437 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7438 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7439 msl_info=(MSLInfo *) context;
7440 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7441 (void) vsprintf(reason,format,operands);
7443 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7445 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7449 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7461 Called when a pcdata block has been parsed.
7463 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7464 " SAX.pcdata(%s, %d)",value,length);
7465 msl_info=(MSLInfo *) context;
7466 parser=msl_info->parser;
7467 child=xmlGetLastChild(parser->node);
7468 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7470 xmlTextConcat(child,value,length);
7473 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7476 static void MSLExternalSubset(void *context,const xmlChar *name,
7477 const xmlChar *external_id,const xmlChar *system_id)
7492 Does this document has an external subset?
7494 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7495 " SAX.externalSubset(%s %s %s)",name,
7496 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7497 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7498 msl_info=(MSLInfo *) context;
7499 parser=msl_info->parser;
7500 if (((external_id == NULL) && (system_id == NULL)) ||
7501 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7502 (msl_info->document == 0)))
7504 input=MSLResolveEntity(context,external_id,system_id);
7507 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7508 parser_context=(*parser);
7509 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7510 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7512 parser->errNo=XML_ERR_NO_MEMORY;
7513 parser->input=parser_context.input;
7514 parser->inputNr=parser_context.inputNr;
7515 parser->inputMax=parser_context.inputMax;
7516 parser->inputTab=parser_context.inputTab;
7522 xmlPushInput(parser,input);
7523 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7524 if (input->filename == (char *) NULL)
7525 input->filename=(char *) xmlStrdup(system_id);
7528 input->base=parser->input->cur;
7529 input->cur=parser->input->cur;
7531 xmlParseExternalSubset(parser,external_id,system_id);
7532 while (parser->inputNr > 1)
7533 (void) xmlPopInput(parser);
7534 xmlFreeInputStream(parser->input);
7535 xmlFree(parser->inputTab);
7536 parser->input=parser_context.input;
7537 parser->inputNr=parser_context.inputNr;
7538 parser->inputMax=parser_context.inputMax;
7539 parser->inputTab=parser_context.inputTab;
7542 #if defined(__cplusplus) || defined(c_plusplus)
7546 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7547 ExceptionInfo *exception)
7550 message[MaxTextExtent];
7573 assert(image_info != (const ImageInfo *) NULL);
7574 assert(image_info->signature == MagickSignature);
7575 if (image_info->debug != MagickFalse)
7576 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7577 image_info->filename);
7578 assert(image != (Image **) NULL);
7579 msl_image=AcquireImage(image_info);
7580 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7581 if (status == MagickFalse)
7583 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7584 msl_image->filename);
7585 msl_image=DestroyImageList(msl_image);
7586 return(MagickFalse);
7588 msl_image->columns=1;
7593 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7594 msl_info.exception=exception;
7595 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7596 sizeof(*msl_info.image_info));
7597 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7598 sizeof(*msl_info.draw_info));
7599 /* top of the stack is the MSL file itself */
7600 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7601 msl_info.attributes=(Image **) AcquireMagickMemory(
7602 sizeof(*msl_info.attributes));
7603 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7604 sizeof(*msl_info.group_info));
7605 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7606 (msl_info.image == (Image **) NULL) ||
7607 (msl_info.attributes == (Image **) NULL) ||
7608 (msl_info.group_info == (MSLGroupInfo *) NULL))
7609 ThrowFatalException(ResourceLimitFatalError,
7610 "UnableToInterpretMSLImage");
7611 *msl_info.image_info=CloneImageInfo(image_info);
7612 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7613 *msl_info.attributes=AcquireImage(image_info);
7614 msl_info.group_info[0].numImages=0;
7615 /* the first slot is used to point to the MSL file image */
7616 *msl_info.image=msl_image;
7617 if (*image != (Image *) NULL)
7618 MSLPushImage(&msl_info,*image);
7619 (void) xmlSubstituteEntitiesDefault(1);
7620 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7621 sax_modules.internalSubset=MSLInternalSubset;
7622 sax_modules.isStandalone=MSLIsStandalone;
7623 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7624 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7625 sax_modules.resolveEntity=MSLResolveEntity;
7626 sax_modules.getEntity=MSLGetEntity;
7627 sax_modules.entityDecl=MSLEntityDeclaration;
7628 sax_modules.notationDecl=MSLNotationDeclaration;
7629 sax_modules.attributeDecl=MSLAttributeDeclaration;
7630 sax_modules.elementDecl=MSLElementDeclaration;
7631 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7632 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7633 sax_modules.startDocument=MSLStartDocument;
7634 sax_modules.endDocument=MSLEndDocument;
7635 sax_modules.startElement=MSLStartElement;
7636 sax_modules.endElement=MSLEndElement;
7637 sax_modules.reference=MSLReference;
7638 sax_modules.characters=MSLCharacters;
7639 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7640 sax_modules.processingInstruction=MSLProcessingInstructions;
7641 sax_modules.comment=MSLComment;
7642 sax_modules.warning=MSLWarning;
7643 sax_modules.error=MSLError;
7644 sax_modules.fatalError=MSLError;
7645 sax_modules.getParameterEntity=MSLGetParameterEntity;
7646 sax_modules.cdataBlock=MSLCDataBlock;
7647 sax_modules.externalSubset=MSLExternalSubset;
7648 sax_handler=(&sax_modules);
7649 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7650 msl_image->filename);
7651 while (ReadBlobString(msl_image,message) != (char *) NULL)
7653 n=(ssize_t) strlen(message);
7656 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7659 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7660 if (msl_info.exception->severity >= ErrorException)
7663 if (msl_info.exception->severity == UndefinedException)
7664 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7665 xmlFreeParserCtxt(msl_info.parser);
7666 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7668 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7669 msl_info.group_info);
7670 if (*image == (Image *) NULL)
7671 *image=(*msl_info.image);
7672 if ((*msl_info.image)->exception.severity != UndefinedException)
7673 return(MagickFalse);
7677 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7685 assert(image_info != (const ImageInfo *) NULL);
7686 assert(image_info->signature == MagickSignature);
7687 if (image_info->debug != MagickFalse)
7688 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7689 image_info->filename);
7690 assert(exception != (ExceptionInfo *) NULL);
7691 assert(exception->signature == MagickSignature);
7692 image=(Image *) NULL;
7693 (void) ProcessMSLScript(image_info,&image,exception);
7694 return(GetFirstImageInList(image));
7699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7703 % R e g i s t e r M S L I m a g e %
7707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7709 % RegisterMSLImage() adds attributes for the MSL image format to
7710 % the list of supported formats. The attributes include the image format
7711 % tag, a method to read and/or write the format, whether the format
7712 % supports the saving of more than one frame to the same file or blob,
7713 % whether the format supports native in-memory I/O, and a brief
7714 % description of the format.
7716 % The format of the RegisterMSLImage method is:
7718 % size_t RegisterMSLImage(void)
7721 ModuleExport size_t RegisterMSLImage(void)
7726 entry=SetMagickInfo("MSL");
7727 #if defined(MAGICKCORE_XML_DELEGATE)
7728 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7729 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7731 entry->description=ConstantString("Magick Scripting Language");
7732 entry->module=ConstantString("MSL");
7733 (void) RegisterMagickInfo(entry);
7734 return(MagickImageCoderSignature);
7737 #if defined(MAGICKCORE_XML_DELEGATE)
7739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7743 % S e t M S L A t t r i b u t e s %
7747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7749 % SetMSLAttributes() ...
7751 % The format of the SetMSLAttributes method is:
7753 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7754 % const char *keyword,const char *value)
7756 % A description of each parameter follows:
7758 % o msl_info: the MSL info.
7760 % o keyword: the keyword.
7762 % o value: the value.
7765 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7792 assert(msl_info != (MSLInfo *) NULL);
7793 if (keyword == (const char *) NULL)
7795 if (value == (const char *) NULL)
7797 exception=msl_info->exception;
7799 attributes=msl_info->attributes[n];
7800 image_info=msl_info->image_info[n];
7801 draw_info=msl_info->draw_info[n];
7802 image=msl_info->image[n];
7808 if (LocaleCompare(keyword,"adjoin") == 0)
7813 adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7815 ThrowMSLException(OptionError,"UnrecognizedType",value);
7816 image_info->adjoin=(MagickBooleanType) adjoin;
7819 if (LocaleCompare(keyword,"alpha") == 0)
7824 alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
7826 ThrowMSLException(OptionError,"UnrecognizedType",value);
7827 if (image != (Image *) NULL)
7828 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7831 if (LocaleCompare(keyword,"antialias") == 0)
7836 antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7838 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7839 image_info->antialias=(MagickBooleanType) antialias;
7842 if (LocaleCompare(keyword,"area-limit") == 0)
7847 limit=MagickResourceInfinity;
7848 if (LocaleCompare(value,"unlimited") != 0)
7849 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7850 (void) SetMagickResourceLimit(AreaResource,limit);
7853 if (LocaleCompare(keyword,"attenuate") == 0)
7855 (void) SetImageOption(image_info,keyword,value);
7858 if (LocaleCompare(keyword,"authenticate") == 0)
7860 (void) CloneString(&image_info->density,value);
7863 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7869 if (LocaleCompare(keyword,"background") == 0)
7871 (void) QueryColorDatabase(value,&image_info->background_color,
7875 if (LocaleCompare(keyword,"bias") == 0)
7877 if (image == (Image *) NULL)
7879 image->bias=SiPrefixToDouble(value,QuantumRange);
7882 if (LocaleCompare(keyword,"blue-primary") == 0)
7884 if (image == (Image *) NULL)
7886 flags=ParseGeometry(value,&geometry_info);
7887 image->chromaticity.blue_primary.x=geometry_info.rho;
7888 image->chromaticity.blue_primary.y=geometry_info.sigma;
7889 if ((flags & SigmaValue) == 0)
7890 image->chromaticity.blue_primary.y=
7891 image->chromaticity.blue_primary.x;
7894 if (LocaleCompare(keyword,"bordercolor") == 0)
7896 (void) QueryColorDatabase(value,&image_info->border_color,
7900 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7906 if (LocaleCompare(keyword,"density") == 0)
7908 (void) CloneString(&image_info->density,value);
7909 (void) CloneString(&draw_info->density,value);
7912 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7918 if (LocaleCompare(keyword,"fill") == 0)
7920 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7921 (void) SetImageOption(image_info,keyword,value);
7924 if (LocaleCompare(keyword,"filename") == 0)
7926 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7929 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7935 if (LocaleCompare(keyword,"gravity") == 0)
7940 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
7942 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7943 (void) SetImageOption(image_info,keyword,value);
7946 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7952 if (LocaleCompare(keyword,"id") == 0)
7954 (void) SetImageProperty(attributes,keyword,value);
7957 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7963 if (LocaleCompare(keyword,"magick") == 0)
7965 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7968 if (LocaleCompare(keyword,"mattecolor") == 0)
7970 (void) QueryColorDatabase(value,&image_info->matte_color,
7974 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7980 if (LocaleCompare(keyword,"pointsize") == 0)
7982 image_info->pointsize=StringToDouble(value);
7983 draw_info->pointsize=StringToDouble(value);
7986 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7992 if (LocaleCompare(keyword,"quality") == 0)
7994 image_info->quality=StringToLong(value);
7995 if (image == (Image *) NULL)
7997 image->quality=StringToLong(value);
8005 if (LocaleCompare(keyword,"size") == 0)
8007 (void) CloneString(&image_info->size,value);
8010 if (LocaleCompare(keyword,"stroke") == 0)
8012 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8013 (void) SetImageOption(image_info,keyword,value);
8016 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8021 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8034 % U n r e g i s t e r M S L I m a g e %
8038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8040 % UnregisterMSLImage() removes format registrations made by the
8041 % MSL module from the list of supported formats.
8043 % The format of the UnregisterMSLImage method is:
8045 % UnregisterMSLImage(void)
8048 ModuleExport void UnregisterMSLImage(void)
8050 (void) UnregisterMagickInfo("MSL");
8053 #if defined(MAGICKCORE_XML_DELEGATE)
8055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8059 % W r i t e M S L I m a g e %
8063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8065 % WriteMSLImage() writes an image to a file in MVG image format.
8067 % The format of the WriteMSLImage method is:
8069 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8071 % A description of each parameter follows.
8073 % o image_info: the image info.
8075 % o image: The image.
8078 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8080 assert(image_info != (const ImageInfo *) NULL);
8081 assert(image_info->signature == MagickSignature);
8082 assert(image != (Image *) NULL);
8083 assert(image->signature == MagickSignature);
8084 if (image->debug != MagickFalse)
8085 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8086 (void) ReferenceImage(image);
8087 (void) ProcessMSLScript(image_info,&image,&image->exception);