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,"%lux%lu%+ld%+ld",
1065 (unsigned long) geometry.width,(unsigned long) geometry.height,
1066 (long) geometry.x,(long) geometry.y);
1067 CloneString(&draw_info->geometry,text);
1068 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1069 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1070 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1071 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1072 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
1074 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.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+=height)
1988 for (x=0; x < (ssize_t) image->columns; x+=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 "%lux%lu%+ld%+ld",(unsigned long) composite_image->columns,
2044 (unsigned long) composite_image->rows,(long) geometry.x,(long)
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,"%lux%lu%+ld%+ld",
2655 (unsigned long) geometry.width,(unsigned long) geometry.height,
2656 (long) geometry.x,(long) geometry.y);
2657 CloneString(&draw_info->geometry,text);
2658 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
2659 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
2660 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
2661 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
2662 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
2664 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.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,"%lu",
3269 (unsigned long) 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,"%lu",
3281 (unsigned long) 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,"%lux%lu%+ld%+ld",
4798 (unsigned long) geometry.width,(unsigned long) geometry.height,
4799 (long) geometry.x,(long) geometry.y);
4800 CloneString(&draw_info->geometry,text);
4801 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
4802 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
4803 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
4804 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
4805 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
4807 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.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,"%lux%lu",
6052 (unsigned long) geometry.width,(unsigned long)
6054 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6055 (void) FormatMagickString(page,MaxTextExtent,
6056 "%lux%lu%+ld%+ld",(unsigned long) geometry.width,
6057 (unsigned long) geometry.height,(long) geometry.x,(long)
6059 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6060 msl_info->image_info[n]->page=GetPageGeometry(page);
6063 (void) SetMSLAttributes(msl_info,keyword,value);
6068 (void) SetMSLAttributes(msl_info,keyword,value);
6075 if (LocaleCompare((const char *) tag,"shade") == 0)
6086 if (msl_info->image[n] == (Image *) NULL)
6088 ThrowMSLException(OptionError,"NoImagesDefined",
6089 (const char *) tag);
6093 if (attributes != (const xmlChar **) NULL)
6094 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6096 keyword=(const char *) attributes[i++];
6097 attribute=InterpretImageProperties(msl_info->image_info[n],
6098 msl_info->attributes[n],(const char *) attributes[i]);
6099 CloneString(&value,attribute);
6105 if (LocaleCompare(keyword,"azimuth") == 0)
6107 geometry_info.rho=StringToDouble(value);
6110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6117 if (LocaleCompare(keyword,"elevation") == 0)
6119 geometry_info.sigma=StringToDouble(value);
6122 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6129 if (LocaleCompare(keyword,"geometry") == 0)
6131 flags=ParseGeometry(value,&geometry_info);
6132 if ((flags & SigmaValue) == 0)
6133 geometry_info.sigma=1.0;
6136 if (LocaleCompare(keyword,"gray") == 0)
6138 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6141 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6143 gray=(MagickBooleanType) option;
6146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6158 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6159 geometry_info.sigma,&msl_info->image[n]->exception);
6160 if (shade_image == (Image *) NULL)
6162 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6163 msl_info->image[n]=shade_image;
6166 if (LocaleCompare((const char *) tag,"shadow") == 0)
6174 if (msl_info->image[n] == (Image *) NULL)
6176 ThrowMSLException(OptionError,"NoImagesDefined",
6177 (const char *) tag);
6180 if (attributes != (const xmlChar **) NULL)
6181 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6183 keyword=(const char *) attributes[i++];
6184 attribute=InterpretImageProperties(msl_info->image_info[n],
6185 msl_info->attributes[n],(const char *) attributes[i]);
6186 CloneString(&value,attribute);
6192 if (LocaleCompare(keyword,"geometry") == 0)
6194 flags=ParseGeometry(value,&geometry_info);
6195 if ((flags & SigmaValue) == 0)
6196 geometry_info.sigma=1.0;
6199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6206 if (LocaleCompare(keyword,"opacity") == 0)
6208 geometry_info.rho=StringToLong(value);
6211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6218 if (LocaleCompare(keyword,"sigma") == 0)
6220 geometry_info.sigma=StringToLong(value);
6228 if (LocaleCompare(keyword,"x") == 0)
6230 geometry_info.xi=StringToDouble(value);
6233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6240 if (LocaleCompare(keyword,"y") == 0)
6242 geometry_info.psi=StringToLong(value);
6245 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6251 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6257 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6258 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6259 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6260 if (shadow_image == (Image *) NULL)
6262 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6263 msl_info->image[n]=shadow_image;
6266 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6268 double radius = 0.0,
6271 if (msl_info->image[n] == (Image *) NULL)
6273 ThrowMSLException(OptionError,"NoImagesDefined",
6274 (const char *) tag);
6278 NOTE: sharpen can have no attributes, since we use all the defaults!
6280 if (attributes != (const xmlChar **) NULL)
6282 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6284 keyword=(const char *) attributes[i++];
6285 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6286 msl_info->attributes[n],(const char *) attributes[i]));
6292 if (LocaleCompare(keyword, "radius") == 0)
6294 radius = StringToDouble( value );
6297 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6303 if (LocaleCompare(keyword,"sigma") == 0)
6305 sigma = StringToLong( value );
6308 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6327 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6328 if (newImage == (Image *) NULL)
6330 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6331 msl_info->image[n]=newImage;
6335 else if (LocaleCompare((const char *) tag,"shave") == 0)
6337 /* init the values */
6341 if (msl_info->image[n] == (Image *) NULL)
6343 ThrowMSLException(OptionError,"NoImagesDefined",
6344 (const char *) tag);
6347 if (attributes == (const xmlChar **) NULL)
6349 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6351 keyword=(const char *) attributes[i++];
6352 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6353 msl_info->attributes[n],(const char *) attributes[i]));
6359 if (LocaleCompare(keyword,"geometry") == 0)
6361 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6364 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6370 if (LocaleCompare(keyword,"height") == 0)
6372 height = StringToLong( value );
6375 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6381 if (LocaleCompare(keyword,"width") == 0)
6383 width = StringToLong( value );
6386 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6391 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6406 rectInfo.height = height;
6407 rectInfo.width = width;
6412 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6413 &msl_info->image[n]->exception);
6414 if (newImage == (Image *) NULL)
6416 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6417 msl_info->image[n]=newImage;
6422 if (LocaleCompare((const char *) tag,"shear") == 0)
6430 if (msl_info->image[n] == (Image *) NULL)
6432 ThrowMSLException(OptionError,"NoImagesDefined",
6433 (const char *) tag);
6436 if (attributes != (const xmlChar **) NULL)
6437 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6439 keyword=(const char *) attributes[i++];
6440 attribute=InterpretImageProperties(msl_info->image_info[n],
6441 msl_info->attributes[n],(const char *) attributes[i]);
6442 CloneString(&value,attribute);
6448 if (LocaleCompare(keyword, "fill") == 0)
6450 (void) QueryColorDatabase(value,
6451 &msl_info->image[n]->background_color,&exception);
6454 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6461 if (LocaleCompare(keyword,"geometry") == 0)
6463 flags=ParseGeometry(value,&geometry_info);
6464 if ((flags & SigmaValue) == 0)
6465 geometry_info.sigma=1.0;
6468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6475 if (LocaleCompare(keyword,"x") == 0)
6477 geometry_info.rho=StringToDouble(value);
6480 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6487 if (LocaleCompare(keyword,"y") == 0)
6489 geometry_info.sigma=StringToLong(value);
6492 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6498 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6504 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6505 geometry_info.sigma,&msl_info->image[n]->exception);
6506 if (shear_image == (Image *) NULL)
6508 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6509 msl_info->image[n]=shear_image;
6512 if (LocaleCompare((const char *) tag,"signature") == 0)
6517 if (msl_info->image[n] == (Image *) NULL)
6519 ThrowMSLException(OptionError,"NoImagesDefined",
6520 (const char *) tag);
6523 if (attributes != (const xmlChar **) NULL)
6524 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6526 keyword=(const char *) attributes[i++];
6527 attribute=InterpretImageProperties(msl_info->image_info[n],
6528 msl_info->attributes[n],(const char *) attributes[i]);
6529 CloneString(&value,attribute);
6534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6540 (void) SignatureImage(msl_info->image[n]);
6543 if (LocaleCompare((const char *) tag,"solarize") == 0)
6548 if (msl_info->image[n] == (Image *) NULL)
6550 ThrowMSLException(OptionError,"NoImagesDefined",
6551 (const char *) tag);
6554 geometry_info.rho=QuantumRange/2.0;
6555 if (attributes != (const xmlChar **) NULL)
6556 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6558 keyword=(const char *) attributes[i++];
6559 attribute=InterpretImageProperties(msl_info->image_info[n],
6560 msl_info->attributes[n],(const char *) attributes[i]);
6561 CloneString(&value,attribute);
6567 if (LocaleCompare(keyword,"geometry") == 0)
6569 flags=ParseGeometry(value,&geometry_info);
6572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6579 if (LocaleCompare(keyword,"threshold") == 0)
6581 geometry_info.rho=StringToDouble(value);
6584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6596 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6599 if (LocaleCompare((const char *) tag,"spread") == 0)
6607 if (msl_info->image[n] == (Image *) NULL)
6609 ThrowMSLException(OptionError,"NoImagesDefined",
6610 (const char *) tag);
6613 if (attributes != (const xmlChar **) NULL)
6614 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6616 keyword=(const char *) attributes[i++];
6617 attribute=InterpretImageProperties(msl_info->image_info[n],
6618 msl_info->attributes[n],(const char *) attributes[i]);
6619 CloneString(&value,attribute);
6625 if (LocaleCompare(keyword,"geometry") == 0)
6627 flags=ParseGeometry(value,&geometry_info);
6628 if ((flags & SigmaValue) == 0)
6629 geometry_info.sigma=1.0;
6632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6639 if (LocaleCompare(keyword,"radius") == 0)
6641 geometry_info.rho=StringToDouble(value);
6644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6656 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6657 &msl_info->image[n]->exception);
6658 if (spread_image == (Image *) NULL)
6660 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6661 msl_info->image[n]=spread_image;
6664 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6667 watermark = (Image*)NULL;
6669 if (msl_info->image[n] == (Image *) NULL)
6671 ThrowMSLException(OptionError,"NoImagesDefined",
6672 (const char *) tag);
6675 if (attributes == (const xmlChar **) NULL)
6677 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6679 keyword=(const char *) attributes[i++];
6680 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6681 msl_info->attributes[n],(const char *) attributes[i]));
6687 if (LocaleCompare(keyword,"image") == 0)
6689 for (j=0; j<msl_info->n;j++)
6692 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6693 if (theAttr && LocaleCompare(theAttr, value) == 0)
6695 watermark = msl_info->image[j];
6701 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6706 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6715 if ( watermark != (Image*) NULL )
6720 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6721 if (newImage == (Image *) NULL)
6723 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6724 msl_info->image[n]=newImage;
6727 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6729 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6732 stereoImage = (Image*)NULL;
6734 if (msl_info->image[n] == (Image *) NULL)
6736 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6739 if (attributes == (const xmlChar **) NULL)
6741 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6743 keyword=(const char *) attributes[i++];
6744 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6745 msl_info->attributes[n],(const char *) attributes[i]));
6751 if (LocaleCompare(keyword,"image") == 0)
6753 for (j=0; j<msl_info->n;j++)
6756 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6757 if (theAttr && LocaleCompare(theAttr, value) == 0)
6759 stereoImage = msl_info->image[j];
6765 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6770 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6779 if ( stereoImage != (Image*) NULL )
6784 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6785 if (newImage == (Image *) NULL)
6787 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6788 msl_info->image[n]=newImage;
6791 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6793 if (LocaleCompare((const char *) tag,"swap") == 0)
6804 if (msl_info->image[n] == (Image *) NULL)
6806 ThrowMSLException(OptionError,"NoImagesDefined",
6807 (const char *) tag);
6812 if (attributes != (const xmlChar **) NULL)
6813 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6815 keyword=(const char *) attributes[i++];
6816 attribute=InterpretImageProperties(msl_info->image_info[n],
6817 msl_info->attributes[n],(const char *) attributes[i]);
6818 CloneString(&value,attribute);
6824 if (LocaleCompare(keyword,"indexes") == 0)
6826 flags=ParseGeometry(value,&geometry_info);
6827 index=(ssize_t) geometry_info.rho;
6828 if ((flags & SigmaValue) == 0)
6829 swap_index=(ssize_t) geometry_info.sigma;
6832 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6847 p=GetImageFromList(msl_info->image[n],index);
6848 q=GetImageFromList(msl_info->image[n],swap_index);
6849 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6851 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6854 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6855 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6856 ReplaceImageInList(&q,swap);
6857 msl_info->image[n]=GetFirstImageInList(q);
6860 if (LocaleCompare((const char *) tag,"swirl") == 0)
6868 if (msl_info->image[n] == (Image *) NULL)
6870 ThrowMSLException(OptionError,"NoImagesDefined",
6871 (const char *) tag);
6874 if (attributes != (const xmlChar **) NULL)
6875 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6877 keyword=(const char *) attributes[i++];
6878 attribute=InterpretImageProperties(msl_info->image_info[n],
6879 msl_info->attributes[n],(const char *) attributes[i]);
6880 CloneString(&value,attribute);
6886 if (LocaleCompare(keyword,"degrees") == 0)
6888 geometry_info.rho=StringToDouble(value);
6891 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6898 if (LocaleCompare(keyword,"geometry") == 0)
6900 flags=ParseGeometry(value,&geometry_info);
6901 if ((flags & SigmaValue) == 0)
6902 geometry_info.sigma=1.0;
6905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6911 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6917 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6918 &msl_info->image[n]->exception);
6919 if (swirl_image == (Image *) NULL)
6921 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6922 msl_info->image[n]=swirl_image;
6925 if (LocaleCompare((const char *) tag,"sync") == 0)
6930 if (msl_info->image[n] == (Image *) NULL)
6932 ThrowMSLException(OptionError,"NoImagesDefined",
6933 (const char *) tag);
6936 if (attributes != (const xmlChar **) NULL)
6937 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6939 keyword=(const char *) attributes[i++];
6940 attribute=InterpretImageProperties(msl_info->image_info[n],
6941 msl_info->attributes[n],(const char *) attributes[i]);
6942 CloneString(&value,attribute);
6947 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6953 (void) SyncImage(msl_info->image[n]);
6956 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6961 if (LocaleCompare((const char *) tag,"map") == 0)
6969 if (msl_info->image[n] == (Image *) NULL)
6971 ThrowMSLException(OptionError,"NoImagesDefined",
6972 (const char *) tag);
6975 texture_image=NewImageList();
6976 if (attributes != (const xmlChar **) NULL)
6977 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6979 keyword=(const char *) attributes[i++];
6980 attribute=InterpretImageProperties(msl_info->image_info[n],
6981 msl_info->attributes[n],(const char *) attributes[i]);
6982 CloneString(&value,attribute);
6988 if (LocaleCompare(keyword,"image") == 0)
6989 for (j=0; j < msl_info->n; j++)
6994 attribute=GetImageProperty(msl_info->attributes[j],"id");
6995 if ((attribute != (const char *) NULL) &&
6996 (LocaleCompare(attribute,value) == 0))
6998 texture_image=CloneImage(msl_info->image[j],0,0,
6999 MagickFalse,&exception);
7007 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7013 (void) TextureImage(msl_info->image[n],texture_image);
7014 texture_image=DestroyImage(texture_image);
7017 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7019 /* init the values */
7020 double threshold = 0;
7022 if (msl_info->image[n] == (Image *) NULL)
7024 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7027 if (attributes == (const xmlChar **) NULL)
7029 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7031 keyword=(const char *) attributes[i++];
7032 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7033 msl_info->attributes[n],(const char *) attributes[i]));
7039 if (LocaleCompare(keyword,"threshold") == 0)
7041 threshold = StringToDouble( value );
7044 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7049 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7059 BilevelImageChannel(msl_info->image[n],
7060 (ChannelType) ((ssize_t) (AllChannels &~ (ssize_t) OpacityChannel)),
7065 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7067 if (msl_info->image[n] == (Image *) NULL)
7069 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7072 if (attributes == (const xmlChar **) NULL)
7074 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7076 keyword=(const char *) attributes[i++];
7077 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7078 msl_info->attributes[n],(const char *) attributes[i]));
7084 if (LocaleCompare(keyword,"color") == 0)
7089 (void) QueryMagickColor(value,&target,&exception);
7090 (void) TransparentPaintImage(msl_info->image[n],&target,
7091 TransparentOpacity,MagickFalse);
7094 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7099 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7106 else if (LocaleCompare((const char *) tag, "trim") == 0)
7108 if (msl_info->image[n] == (Image *) NULL)
7110 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7114 /* no attributes here */
7116 /* process the image */
7123 /* all zeros on a crop == trim edges! */
7124 rectInfo.height = rectInfo.width = 0;
7125 rectInfo.x = rectInfo.y = 0;
7127 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7128 if (newImage == (Image *) NULL)
7130 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7131 msl_info->image[n]=newImage;
7135 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7140 if (LocaleCompare((const char *) tag,"write") == 0)
7142 if (msl_info->image[n] == (Image *) NULL)
7144 ThrowMSLException(OptionError,"NoImagesDefined",
7145 (const char *) tag);
7148 if (attributes == (const xmlChar **) NULL)
7150 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7152 keyword=(const char *) attributes[i++];
7153 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7154 msl_info->attributes[n],(const char *) attributes[i]));
7160 if (LocaleCompare(keyword,"filename") == 0)
7162 (void) CopyMagickString(msl_info->image[n]->filename,value,
7166 (void) SetMSLAttributes(msl_info,keyword,value);
7170 (void) SetMSLAttributes(msl_info,keyword,value);
7178 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7182 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7186 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7190 if ( value != NULL )
7191 value=DestroyString(value);
7192 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7195 static void MSLEndElement(void *context,const xmlChar *tag)
7204 Called when the end of an element has been detected.
7206 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7208 msl_info=(MSLInfo *) context;
7215 if (LocaleCompare((const char *) tag,"comment") == 0 )
7217 (void) DeleteImageProperty(msl_info->image[n],"comment");
7218 if (msl_info->content == (char *) NULL)
7220 StripString(msl_info->content);
7221 (void) SetImageProperty(msl_info->image[n],"comment",
7230 if (LocaleCompare((const char *) tag, "group") == 0 )
7232 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7234 ssize_t i = (ssize_t)
7235 (msl_info->group_info[msl_info->number_groups-1].numImages);
7238 if (msl_info->image[msl_info->n] != (Image *) NULL)
7239 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7240 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7241 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7245 msl_info->number_groups--;
7252 if (LocaleCompare((const char *) tag, "image") == 0)
7253 MSLPopImage(msl_info);
7259 if (LocaleCompare((const char *) tag,"label") == 0 )
7261 (void) DeleteImageProperty(msl_info->image[n],"label");
7262 if (msl_info->content == (char *) NULL)
7264 StripString(msl_info->content);
7265 (void) SetImageProperty(msl_info->image[n],"label",
7274 if (LocaleCompare((const char *) tag, "msl") == 0 )
7277 This our base element.
7278 at the moment we don't do anything special
7279 but someday we might!
7287 if (msl_info->content != (char *) NULL)
7288 msl_info->content=DestroyString(msl_info->content);
7291 static void MSLCharacters(void *context,const xmlChar *c,int length)
7303 Receiving some characters from the parser.
7305 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7306 " SAX.characters(%s,%d)",c,length);
7307 msl_info=(MSLInfo *) context;
7308 if (msl_info->content != (char *) NULL)
7309 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7310 strlen(msl_info->content)+length+MaxTextExtent,
7311 sizeof(*msl_info->content));
7314 msl_info->content=(char *) NULL;
7315 if (~length >= MaxTextExtent)
7316 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7317 sizeof(*msl_info->content));
7318 if (msl_info->content != (char *) NULL)
7319 *msl_info->content='\0';
7321 if (msl_info->content == (char *) NULL)
7323 p=msl_info->content+strlen(msl_info->content);
7324 for (i=0; i < length; i++)
7329 static void MSLReference(void *context,const xmlChar *name)
7338 Called when an entity reference is detected.
7340 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7341 " SAX.reference(%s)",name);
7342 msl_info=(MSLInfo *) context;
7343 parser=msl_info->parser;
7345 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7347 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7350 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7356 Receiving some ignorable whitespaces from the parser.
7358 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7359 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7360 msl_info=(MSLInfo *) context;
7363 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7364 const xmlChar *data)
7370 A processing instruction has been parsed.
7372 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7373 " SAX.processingInstruction(%s, %s)",
7375 msl_info=(MSLInfo *) context;
7378 static void MSLComment(void *context,const xmlChar *value)
7384 A comment has been parsed.
7386 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7387 " SAX.comment(%s)",value);
7388 msl_info=(MSLInfo *) context;
7391 static void MSLWarning(void *context,const char *format,...)
7395 reason[MaxTextExtent];
7404 Display and format a warning messages, gives file, line, position and
7407 va_start(operands,format);
7408 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7409 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7410 msl_info=(MSLInfo *) context;
7411 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7412 (void) vsprintf(reason,format,operands);
7414 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7416 message=GetExceptionMessage(errno);
7417 ThrowMSLException(CoderError,reason,message);
7418 message=DestroyString(message);
7422 static void MSLError(void *context,const char *format,...)
7425 reason[MaxTextExtent];
7434 Display and format a error formats, gives file, line, position and
7437 va_start(operands,format);
7438 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7439 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7440 msl_info=(MSLInfo *) context;
7441 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7442 (void) vsprintf(reason,format,operands);
7444 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7446 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7450 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7462 Called when a pcdata block has been parsed.
7464 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7465 " SAX.pcdata(%s, %d)",value,length);
7466 msl_info=(MSLInfo *) context;
7467 parser=msl_info->parser;
7468 child=xmlGetLastChild(parser->node);
7469 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7471 xmlTextConcat(child,value,length);
7474 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7477 static void MSLExternalSubset(void *context,const xmlChar *name,
7478 const xmlChar *external_id,const xmlChar *system_id)
7493 Does this document has an external subset?
7495 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7496 " SAX.externalSubset(%s %s %s)",name,
7497 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7498 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7499 msl_info=(MSLInfo *) context;
7500 parser=msl_info->parser;
7501 if (((external_id == NULL) && (system_id == NULL)) ||
7502 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7503 (msl_info->document == 0)))
7505 input=MSLResolveEntity(context,external_id,system_id);
7508 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7509 parser_context=(*parser);
7510 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7511 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7513 parser->errNo=XML_ERR_NO_MEMORY;
7514 parser->input=parser_context.input;
7515 parser->inputNr=parser_context.inputNr;
7516 parser->inputMax=parser_context.inputMax;
7517 parser->inputTab=parser_context.inputTab;
7523 xmlPushInput(parser,input);
7524 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7525 if (input->filename == (char *) NULL)
7526 input->filename=(char *) xmlStrdup(system_id);
7529 input->base=parser->input->cur;
7530 input->cur=parser->input->cur;
7532 xmlParseExternalSubset(parser,external_id,system_id);
7533 while (parser->inputNr > 1)
7534 (void) xmlPopInput(parser);
7535 xmlFreeInputStream(parser->input);
7536 xmlFree(parser->inputTab);
7537 parser->input=parser_context.input;
7538 parser->inputNr=parser_context.inputNr;
7539 parser->inputMax=parser_context.inputMax;
7540 parser->inputTab=parser_context.inputTab;
7543 #if defined(__cplusplus) || defined(c_plusplus)
7547 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7548 ExceptionInfo *exception)
7551 message[MaxTextExtent];
7574 assert(image_info != (const ImageInfo *) NULL);
7575 assert(image_info->signature == MagickSignature);
7576 if (image_info->debug != MagickFalse)
7577 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7578 image_info->filename);
7579 assert(image != (Image **) NULL);
7580 msl_image=AcquireImage(image_info);
7581 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7582 if (status == MagickFalse)
7584 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7585 msl_image->filename);
7586 msl_image=DestroyImageList(msl_image);
7587 return(MagickFalse);
7589 msl_image->columns=1;
7594 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7595 msl_info.exception=exception;
7596 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7597 sizeof(*msl_info.image_info));
7598 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7599 sizeof(*msl_info.draw_info));
7600 /* top of the stack is the MSL file itself */
7601 msl_info.image=(Image **) AcquireAlignedMemory(1,sizeof(*msl_info.image));
7602 msl_info.attributes=(Image **) AcquireMagickMemory(
7603 sizeof(*msl_info.attributes));
7604 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7605 sizeof(*msl_info.group_info));
7606 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7607 (msl_info.image == (Image **) NULL) ||
7608 (msl_info.attributes == (Image **) NULL) ||
7609 (msl_info.group_info == (MSLGroupInfo *) NULL))
7610 ThrowFatalException(ResourceLimitFatalError,
7611 "UnableToInterpretMSLImage");
7612 *msl_info.image_info=CloneImageInfo(image_info);
7613 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7614 *msl_info.attributes=AcquireImage(image_info);
7615 msl_info.group_info[0].numImages=0;
7616 /* the first slot is used to point to the MSL file image */
7617 *msl_info.image=msl_image;
7618 if (*image != (Image *) NULL)
7619 MSLPushImage(&msl_info,*image);
7620 (void) xmlSubstituteEntitiesDefault(1);
7621 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7622 sax_modules.internalSubset=MSLInternalSubset;
7623 sax_modules.isStandalone=MSLIsStandalone;
7624 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7625 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7626 sax_modules.resolveEntity=MSLResolveEntity;
7627 sax_modules.getEntity=MSLGetEntity;
7628 sax_modules.entityDecl=MSLEntityDeclaration;
7629 sax_modules.notationDecl=MSLNotationDeclaration;
7630 sax_modules.attributeDecl=MSLAttributeDeclaration;
7631 sax_modules.elementDecl=MSLElementDeclaration;
7632 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7633 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7634 sax_modules.startDocument=MSLStartDocument;
7635 sax_modules.endDocument=MSLEndDocument;
7636 sax_modules.startElement=MSLStartElement;
7637 sax_modules.endElement=MSLEndElement;
7638 sax_modules.reference=MSLReference;
7639 sax_modules.characters=MSLCharacters;
7640 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7641 sax_modules.processingInstruction=MSLProcessingInstructions;
7642 sax_modules.comment=MSLComment;
7643 sax_modules.warning=MSLWarning;
7644 sax_modules.error=MSLError;
7645 sax_modules.fatalError=MSLError;
7646 sax_modules.getParameterEntity=MSLGetParameterEntity;
7647 sax_modules.cdataBlock=MSLCDataBlock;
7648 sax_modules.externalSubset=MSLExternalSubset;
7649 sax_handler=(&sax_modules);
7650 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7651 msl_image->filename);
7652 while (ReadBlobString(msl_image,message) != (char *) NULL)
7654 n=(ssize_t) strlen(message);
7657 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7660 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7661 if (msl_info.exception->severity >= ErrorException)
7664 if (msl_info.exception->severity == UndefinedException)
7665 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7666 xmlFreeParserCtxt(msl_info.parser);
7667 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7669 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7670 msl_info.group_info);
7671 if (*image == (Image *) NULL)
7672 *image=(*msl_info.image);
7673 if ((*msl_info.image)->exception.severity != UndefinedException)
7674 return(MagickFalse);
7678 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7686 assert(image_info != (const ImageInfo *) NULL);
7687 assert(image_info->signature == MagickSignature);
7688 if (image_info->debug != MagickFalse)
7689 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7690 image_info->filename);
7691 assert(exception != (ExceptionInfo *) NULL);
7692 assert(exception->signature == MagickSignature);
7693 image=(Image *) NULL;
7694 (void) ProcessMSLScript(image_info,&image,exception);
7695 return(GetFirstImageInList(image));
7700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7704 % R e g i s t e r M S L I m a g e %
7708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7710 % RegisterMSLImage() adds attributes for the MSL image format to
7711 % the list of supported formats. The attributes include the image format
7712 % tag, a method to read and/or write the format, whether the format
7713 % supports the saving of more than one frame to the same file or blob,
7714 % whether the format supports native in-memory I/O, and a brief
7715 % description of the format.
7717 % The format of the RegisterMSLImage method is:
7719 % size_t RegisterMSLImage(void)
7722 ModuleExport size_t RegisterMSLImage(void)
7727 entry=SetMagickInfo("MSL");
7728 #if defined(MAGICKCORE_XML_DELEGATE)
7729 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7730 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7732 entry->description=ConstantString("Magick Scripting Language");
7733 entry->module=ConstantString("MSL");
7734 (void) RegisterMagickInfo(entry);
7735 return(MagickImageCoderSignature);
7738 #if defined(MAGICKCORE_XML_DELEGATE)
7740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7744 % S e t M S L A t t r i b u t e s %
7748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7750 % SetMSLAttributes() ...
7752 % The format of the SetMSLAttributes method is:
7754 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7755 % const char *keyword,const char *value)
7757 % A description of each parameter follows:
7759 % o msl_info: the MSL info.
7761 % o keyword: the keyword.
7763 % o value: the value.
7766 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7793 assert(msl_info != (MSLInfo *) NULL);
7794 if (keyword == (const char *) NULL)
7796 if (value == (const char *) NULL)
7798 exception=msl_info->exception;
7800 attributes=msl_info->attributes[n];
7801 image_info=msl_info->image_info[n];
7802 draw_info=msl_info->draw_info[n];
7803 image=msl_info->image[n];
7809 if (LocaleCompare(keyword,"adjoin") == 0)
7814 adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7816 ThrowMSLException(OptionError,"UnrecognizedType",value);
7817 image_info->adjoin=(MagickBooleanType) adjoin;
7820 if (LocaleCompare(keyword,"alpha") == 0)
7825 alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
7827 ThrowMSLException(OptionError,"UnrecognizedType",value);
7828 if (image != (Image *) NULL)
7829 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7832 if (LocaleCompare(keyword,"antialias") == 0)
7837 antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7839 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7840 image_info->antialias=(MagickBooleanType) antialias;
7843 if (LocaleCompare(keyword,"area-limit") == 0)
7848 limit=MagickResourceInfinity;
7849 if (LocaleCompare(value,"unlimited") != 0)
7850 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7851 (void) SetMagickResourceLimit(AreaResource,limit);
7854 if (LocaleCompare(keyword,"attenuate") == 0)
7856 (void) SetImageOption(image_info,keyword,value);
7859 if (LocaleCompare(keyword,"authenticate") == 0)
7861 (void) CloneString(&image_info->density,value);
7864 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7870 if (LocaleCompare(keyword,"background") == 0)
7872 (void) QueryColorDatabase(value,&image_info->background_color,
7876 if (LocaleCompare(keyword,"bias") == 0)
7878 if (image == (Image *) NULL)
7880 image->bias=SiPrefixToDouble(value,QuantumRange);
7883 if (LocaleCompare(keyword,"blue-primary") == 0)
7885 if (image == (Image *) NULL)
7887 flags=ParseGeometry(value,&geometry_info);
7888 image->chromaticity.blue_primary.x=geometry_info.rho;
7889 image->chromaticity.blue_primary.y=geometry_info.sigma;
7890 if ((flags & SigmaValue) == 0)
7891 image->chromaticity.blue_primary.y=
7892 image->chromaticity.blue_primary.x;
7895 if (LocaleCompare(keyword,"bordercolor") == 0)
7897 (void) QueryColorDatabase(value,&image_info->border_color,
7901 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7907 if (LocaleCompare(keyword,"density") == 0)
7909 (void) CloneString(&image_info->density,value);
7910 (void) CloneString(&draw_info->density,value);
7913 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7919 if (LocaleCompare(keyword,"fill") == 0)
7921 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7922 (void) SetImageOption(image_info,keyword,value);
7925 if (LocaleCompare(keyword,"filename") == 0)
7927 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7930 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7936 if (LocaleCompare(keyword,"gravity") == 0)
7941 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
7943 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7944 (void) SetImageOption(image_info,keyword,value);
7947 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7953 if (LocaleCompare(keyword,"id") == 0)
7955 (void) SetImageProperty(attributes,keyword,value);
7958 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7964 if (LocaleCompare(keyword,"magick") == 0)
7966 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7969 if (LocaleCompare(keyword,"mattecolor") == 0)
7971 (void) QueryColorDatabase(value,&image_info->matte_color,
7975 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7981 if (LocaleCompare(keyword,"pointsize") == 0)
7983 image_info->pointsize=StringToDouble(value);
7984 draw_info->pointsize=StringToDouble(value);
7987 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7993 if (LocaleCompare(keyword,"quality") == 0)
7995 image_info->quality=StringToLong(value);
7996 if (image == (Image *) NULL)
7998 image->quality=StringToLong(value);
8006 if (LocaleCompare(keyword,"size") == 0)
8008 (void) CloneString(&image_info->size,value);
8011 if (LocaleCompare(keyword,"stroke") == 0)
8013 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8014 (void) SetImageOption(image_info,keyword,value);
8017 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8022 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8035 % U n r e g i s t e r M S L I m a g e %
8039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8041 % UnregisterMSLImage() removes format registrations made by the
8042 % MSL module from the list of supported formats.
8044 % The format of the UnregisterMSLImage method is:
8046 % UnregisterMSLImage(void)
8049 ModuleExport void UnregisterMSLImage(void)
8051 (void) UnregisterMagickInfo("MSL");
8054 #if defined(MAGICKCORE_XML_DELEGATE)
8056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8060 % W r i t e M S L I m a g e %
8064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8066 % WriteMSLImage() writes an image to a file in MVG image format.
8068 % The format of the WriteMSLImage method is:
8070 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8072 % A description of each parameter follows.
8074 % o image_info: the image info.
8076 % o image: The image.
8079 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8081 assert(image_info != (const ImageInfo *) NULL);
8082 assert(image_info->signature == MagickSignature);
8083 assert(image != (Image *) NULL);
8084 assert(image->signature == MagickSignature);
8085 if (image->debug != MagickFalse)
8086 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8087 (void) ReferenceImage(image);
8088 (void) ProcessMSLScript(image_info,&image,&image->exception);