2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "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;
508 static void MSLStartDocument(void *context)
517 Called when the document start being processed.
519 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
520 " SAX.startDocument()");
521 msl_info=(MSLInfo *) context;
522 parser=msl_info->parser;
523 msl_info->document=xmlNewDoc(parser->version);
524 if (msl_info->document == (xmlDocPtr) NULL)
526 if (parser->encoding == NULL)
527 msl_info->document->encoding=NULL;
529 msl_info->document->encoding=xmlStrdup(parser->encoding);
530 msl_info->document->standalone=parser->standalone;
533 static void MSLEndDocument(void *context)
539 Called when the document end has been detected.
541 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
542 msl_info=(MSLInfo *) context;
543 if (msl_info->content != (char *) NULL)
544 msl_info->content=DestroyString(msl_info->content);
547 static void MSLPushImage(MSLInfo *msl_info,Image *image)
552 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
553 assert(msl_info != (MSLInfo *) NULL);
556 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
557 (n+1),sizeof(*msl_info->image_info));
558 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
559 (n+1),sizeof(*msl_info->draw_info));
560 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
561 (n+1),sizeof(*msl_info->attributes));
562 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
563 sizeof(*msl_info->image));
564 if ((msl_info->image_info == (ImageInfo **) NULL) ||
565 (msl_info->draw_info == (DrawInfo **) NULL) ||
566 (msl_info->attributes == (Image **) NULL) ||
567 (msl_info->image == (Image **) NULL))
568 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
569 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
570 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
571 msl_info->draw_info[n-1]);
572 if (image == (Image *) NULL)
573 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
575 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
576 msl_info->image[n]=(Image *) image;
577 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
578 (msl_info->attributes[n] == (Image *) NULL))
579 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
580 if (msl_info->number_groups != 0)
581 msl_info->group_info[msl_info->number_groups-1].numImages++;
584 static void MSLPopImage(MSLInfo *msl_info)
586 if (msl_info->number_groups != 0)
588 if (msl_info->image[msl_info->n] != (Image *) NULL)
589 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
590 msl_info->attributes[msl_info->n]=DestroyImage(
591 msl_info->attributes[msl_info->n]);
592 msl_info->image_info[msl_info->n]=DestroyImageInfo(
593 msl_info->image_info[msl_info->n]);
597 static void MSLStartElement(void *context,const xmlChar *tag,
598 const xmlChar **attributes)
654 Called when an opening tag has been processed.
656 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
657 " SAX.startElement(%s",tag);
658 GetExceptionInfo(&exception);
659 msl_info=(MSLInfo *) context;
661 keyword=(const char *) NULL;
663 SetGeometryInfo(&geometry_info);
664 channel=DefaultChannels;
670 if (LocaleCompare((const char *) tag,"add-noise") == 0)
681 if (msl_info->image[n] == (Image *) NULL)
683 ThrowMSLException(OptionError,"NoImagesDefined",
688 if (attributes != (const xmlChar **) NULL)
689 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
691 keyword=(const char *) attributes[i++];
692 attribute=InterpretImageProperties(msl_info->image_info[n],
693 msl_info->attributes[n],(const char *) attributes[i]);
694 CloneString(&value,attribute);
700 if (LocaleCompare(keyword,"channel") == 0)
702 option=ParseChannelOption(value);
704 ThrowMSLException(OptionError,"UnrecognizedChannelType",
706 channel=(ChannelType) option;
709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
716 if (LocaleCompare(keyword,"noise") == 0)
718 option=ParseMagickOption(MagickNoiseOptions,MagickFalse,
721 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
723 noise=(NoiseType) option;
726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
738 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
739 &msl_info->image[n]->exception);
740 if (noise_image == (Image *) NULL)
742 msl_info->image[n]=DestroyImage(msl_info->image[n]);
743 msl_info->image[n]=noise_image;
746 if (LocaleCompare((const char *) tag,"annotate") == 0)
754 if (msl_info->image[n] == (Image *) NULL)
756 ThrowMSLException(OptionError,"NoImagesDefined",
760 draw_info=CloneDrawInfo(msl_info->image_info[n],
761 msl_info->draw_info[n]);
763 current=draw_info->affine;
764 GetAffineMatrix(&affine);
765 if (attributes != (const xmlChar **) NULL)
766 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
768 keyword=(const char *) attributes[i++];
769 attribute=InterpretImageProperties(msl_info->image_info[n],
770 msl_info->attributes[n],(const char *) attributes[i]);
771 CloneString(&value,attribute);
777 if (LocaleCompare(keyword,"affine") == 0)
783 draw_info->affine.sx=strtod(p,&p);
786 draw_info->affine.rx=strtod(p,&p);
789 draw_info->affine.ry=strtod(p,&p);
792 draw_info->affine.sy=strtod(p,&p);
795 draw_info->affine.tx=strtod(p,&p);
798 draw_info->affine.ty=strtod(p,&p);
801 if (LocaleCompare(keyword,"align") == 0)
803 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
806 ThrowMSLException(OptionError,"UnrecognizedAlignType",
808 draw_info->align=(AlignType) option;
811 if (LocaleCompare(keyword,"antialias") == 0)
813 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
816 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
818 draw_info->stroke_antialias=(MagickBooleanType) option;
819 draw_info->text_antialias=(MagickBooleanType) option;
822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
829 if (LocaleCompare(keyword,"density") == 0)
831 CloneString(&draw_info->density,value);
834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
841 if (LocaleCompare(keyword,"encoding") == 0)
843 CloneString(&draw_info->encoding,value);
846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
853 if (LocaleCompare(keyword, "fill") == 0)
855 (void) QueryColorDatabase(value,&draw_info->fill,
859 if (LocaleCompare(keyword,"family") == 0)
861 CloneString(&draw_info->family,value);
864 if (LocaleCompare(keyword,"font") == 0)
866 CloneString(&draw_info->font,value);
869 ThrowMSLException(OptionError,"UnrecognizedAttribute",
876 if (LocaleCompare(keyword,"geometry") == 0)
878 flags=ParsePageGeometry(msl_info->image[n],value,
879 &geometry,&exception);
880 if ((flags & HeightValue) == 0)
881 geometry.height=geometry.width;
884 if (LocaleCompare(keyword,"gravity") == 0)
886 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
889 ThrowMSLException(OptionError,"UnrecognizedGravityType",
891 draw_info->gravity=(GravityType) option;
894 ThrowMSLException(OptionError,"UnrecognizedAttribute",
901 if (LocaleCompare(keyword,"pointsize") == 0)
903 draw_info->pointsize=StringToDouble(value);
906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
913 if (LocaleCompare(keyword,"rotate") == 0)
915 angle=StringToDouble(value);
916 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
917 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
918 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
919 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
929 if (LocaleCompare(keyword,"scale") == 0)
931 flags=ParseGeometry(value,&geometry_info);
932 if ((flags & SigmaValue) == 0)
933 geometry_info.sigma=1.0;
934 affine.sx=geometry_info.rho;
935 affine.sy=geometry_info.sigma;
938 if (LocaleCompare(keyword,"skewX") == 0)
940 angle=StringToDouble(value);
941 affine.ry=tan(DegreesToRadians(fmod((double) angle,
945 if (LocaleCompare(keyword,"skewY") == 0)
947 angle=StringToDouble(value);
948 affine.rx=tan(DegreesToRadians(fmod((double) angle,
952 if (LocaleCompare(keyword,"stretch") == 0)
954 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
957 ThrowMSLException(OptionError,"UnrecognizedStretchType",
959 draw_info->stretch=(StretchType) option;
962 if (LocaleCompare(keyword, "stroke") == 0)
964 (void) QueryColorDatabase(value,&draw_info->stroke,
968 if (LocaleCompare(keyword,"strokewidth") == 0)
970 draw_info->stroke_width=StringToLong(value);
973 if (LocaleCompare(keyword,"style") == 0)
975 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
978 ThrowMSLException(OptionError,"UnrecognizedStyleType",
980 draw_info->style=(StyleType) option;
983 ThrowMSLException(OptionError,"UnrecognizedAttribute",
990 if (LocaleCompare(keyword,"text") == 0)
992 CloneString(&draw_info->text,value);
995 if (LocaleCompare(keyword,"translate") == 0)
997 flags=ParseGeometry(value,&geometry_info);
998 if ((flags & SigmaValue) == 0)
999 geometry_info.sigma=1.0;
1000 affine.tx=geometry_info.rho;
1001 affine.ty=geometry_info.sigma;
1004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1011 if (LocaleCompare(keyword, "undercolor") == 0)
1013 (void) QueryColorDatabase(value,&draw_info->undercolor,
1017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1024 if (LocaleCompare(keyword,"weight") == 0)
1026 draw_info->weight=StringToLong(value);
1029 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1036 if (LocaleCompare(keyword,"x") == 0)
1038 geometry.x=StringToLong(value);
1041 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1048 if (LocaleCompare(keyword,"y") == 0)
1050 geometry.y=StringToLong(value);
1053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1059 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1065 (void) FormatMagickString(text,MaxTextExtent,
1066 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1067 geometry.height,(double) geometry.x,(double) geometry.y);
1068 CloneString(&draw_info->geometry,text);
1069 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1070 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1071 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1072 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1073 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1075 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1077 (void) AnnotateImage(msl_info->image[n],draw_info);
1078 draw_info=DestroyDrawInfo(draw_info);
1081 if (LocaleCompare((const char *) tag,"append") == 0)
1089 if (msl_info->image[n] == (Image *) NULL)
1091 ThrowMSLException(OptionError,"NoImagesDefined",
1092 (const char *) tag);
1096 if (attributes != (const xmlChar **) NULL)
1097 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1099 keyword=(const char *) attributes[i++];
1100 attribute=InterpretImageProperties(msl_info->image_info[n],
1101 msl_info->attributes[n],(const char *) attributes[i]);
1102 CloneString(&value,attribute);
1108 if (LocaleCompare(keyword,"stack") == 0)
1110 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1113 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1115 stack=(MagickBooleanType) option;
1118 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1124 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1130 append_image=AppendImages(msl_info->image[n],stack,
1131 &msl_info->image[n]->exception);
1132 if (append_image == (Image *) NULL)
1134 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1135 msl_info->image[n]=append_image;
1138 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1144 if (LocaleCompare((const char *) tag,"blur") == 0)
1152 if (msl_info->image[n] == (Image *) NULL)
1154 ThrowMSLException(OptionError,"NoImagesDefined",
1155 (const char *) tag);
1158 if (attributes != (const xmlChar **) NULL)
1159 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1161 keyword=(const char *) attributes[i++];
1162 attribute=InterpretImageProperties(msl_info->image_info[n],
1163 msl_info->attributes[n],(const char *) attributes[i]);
1164 CloneString(&value,attribute);
1170 if (LocaleCompare(keyword,"channel") == 0)
1172 option=ParseChannelOption(value);
1174 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1176 channel=(ChannelType) option;
1179 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1186 if (LocaleCompare(keyword,"geometry") == 0)
1188 flags=ParseGeometry(value,&geometry_info);
1189 if ((flags & SigmaValue) == 0)
1190 geometry_info.sigma=1.0;
1193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1200 if (LocaleCompare(keyword,"radius") == 0)
1202 geometry_info.rho=StringToDouble(value);
1205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1212 if (LocaleCompare(keyword,"sigma") == 0)
1214 geometry_info.sigma=StringToLong(value);
1217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1229 blur_image=BlurImageChannel(msl_info->image[n],channel,
1230 geometry_info.rho,geometry_info.sigma,
1231 &msl_info->image[n]->exception);
1232 if (blur_image == (Image *) NULL)
1234 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1235 msl_info->image[n]=blur_image;
1238 if (LocaleCompare((const char *) tag,"border") == 0)
1246 if (msl_info->image[n] == (Image *) NULL)
1248 ThrowMSLException(OptionError,"NoImagesDefined",
1249 (const char *) tag);
1252 SetGeometry(msl_info->image[n],&geometry);
1253 if (attributes != (const xmlChar **) NULL)
1254 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1256 keyword=(const char *) attributes[i++];
1257 attribute=InterpretImageProperties(msl_info->image_info[n],
1258 msl_info->attributes[n],(const char *) attributes[i]);
1259 CloneString(&value,attribute);
1265 if (LocaleCompare(keyword,"compose") == 0)
1267 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1270 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1272 msl_info->image[n]->compose=(CompositeOperator) option;
1275 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1282 if (LocaleCompare(keyword, "fill") == 0)
1284 (void) QueryColorDatabase(value,
1285 &msl_info->image[n]->border_color,&exception);
1288 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1295 if (LocaleCompare(keyword,"geometry") == 0)
1297 flags=ParsePageGeometry(msl_info->image[n],value,
1298 &geometry,&exception);
1299 if ((flags & HeightValue) == 0)
1300 geometry.height=geometry.width;
1303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1310 if (LocaleCompare(keyword,"height") == 0)
1312 geometry.height=StringToLong(value);
1315 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1322 if (LocaleCompare(keyword,"width") == 0)
1324 geometry.width=StringToLong(value);
1327 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1339 border_image=BorderImage(msl_info->image[n],&geometry,
1340 &msl_info->image[n]->exception);
1341 if (border_image == (Image *) NULL)
1343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1344 msl_info->image[n]=border_image;
1347 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1352 if (LocaleCompare((const char *) tag,"colorize") == 0)
1355 opacity[MaxTextExtent];
1366 if (msl_info->image[n] == (Image *) NULL)
1368 ThrowMSLException(OptionError,"NoImagesDefined",
1369 (const char *) tag);
1372 target=msl_info->image[n]->background_color;
1373 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1374 if (attributes != (const xmlChar **) NULL)
1375 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1377 keyword=(const char *) attributes[i++];
1378 attribute=InterpretImageProperties(msl_info->image_info[n],
1379 msl_info->attributes[n],(const char *) attributes[i]);
1380 CloneString(&value,attribute);
1386 if (LocaleCompare(keyword,"fill") == 0)
1388 (void) QueryColorDatabase(value,&target,
1389 &msl_info->image[n]->exception);
1392 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1399 if (LocaleCompare(keyword,"opacity") == 0)
1401 (void) CopyMagickString(opacity,value,MaxTextExtent);
1404 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1416 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1417 &msl_info->image[n]->exception);
1418 if (colorize_image == (Image *) NULL)
1420 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1421 msl_info->image[n]=colorize_image;
1424 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1426 double radius = 0.0,
1429 if (msl_info->image[n] == (Image *) NULL)
1431 ThrowMSLException(OptionError,"NoImagesDefined",
1432 (const char *) tag);
1436 NOTE: charcoal can have no attributes, since we use all the defaults!
1438 if (attributes != (const xmlChar **) NULL)
1440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1442 keyword=(const char *) attributes[i++];
1443 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1444 msl_info->attributes[n],(const char *) attributes[i]));
1450 if (LocaleCompare(keyword, "radius") == 0)
1452 radius = StringToDouble( value );
1455 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1461 if (LocaleCompare(keyword,"sigma") == 0)
1463 sigma = StringToLong( value );
1466 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1485 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1486 &msl_info->image[n]->exception);
1487 if (newImage == (Image *) NULL)
1489 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1490 msl_info->image[n]=newImage;
1494 if (LocaleCompare((const char *) tag,"chop") == 0)
1502 if (msl_info->image[n] == (Image *) NULL)
1504 ThrowMSLException(OptionError,"NoImagesDefined",
1505 (const char *) tag);
1508 SetGeometry(msl_info->image[n],&geometry);
1509 if (attributes != (const xmlChar **) NULL)
1510 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1512 keyword=(const char *) attributes[i++];
1513 attribute=InterpretImageProperties(msl_info->image_info[n],
1514 msl_info->attributes[n],(const char *) attributes[i]);
1515 CloneString(&value,attribute);
1521 if (LocaleCompare(keyword,"geometry") == 0)
1523 flags=ParsePageGeometry(msl_info->image[n],value,
1524 &geometry,&exception);
1525 if ((flags & HeightValue) == 0)
1526 geometry.height=geometry.width;
1529 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1536 if (LocaleCompare(keyword,"height") == 0)
1538 geometry.height=StringToLong(value);
1541 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1548 if (LocaleCompare(keyword,"width") == 0)
1550 geometry.width=StringToLong(value);
1553 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1560 if (LocaleCompare(keyword,"x") == 0)
1562 geometry.x=StringToLong(value);
1565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1572 if (LocaleCompare(keyword,"y") == 0)
1574 geometry.y=StringToLong(value);
1577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1589 chop_image=ChopImage(msl_info->image[n],&geometry,
1590 &msl_info->image[n]->exception);
1591 if (chop_image == (Image *) NULL)
1593 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1594 msl_info->image[n]=chop_image;
1597 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1606 Color floodfill image.
1608 if (msl_info->image[n] == (Image *) NULL)
1610 ThrowMSLException(OptionError,"NoImagesDefined",
1611 (const char *) tag);
1614 draw_info=CloneDrawInfo(msl_info->image_info[n],
1615 msl_info->draw_info[n]);
1616 SetGeometry(msl_info->image[n],&geometry);
1617 paint_method=FloodfillMethod;
1618 if (attributes != (const xmlChar **) NULL)
1619 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1621 keyword=(const char *) attributes[i++];
1622 attribute=InterpretImageProperties(msl_info->image_info[n],
1623 msl_info->attributes[n],(const char *) attributes[i]);
1624 CloneString(&value,attribute);
1630 if (LocaleCompare(keyword,"bordercolor") == 0)
1632 (void) QueryMagickColor(value,&target,&exception);
1633 paint_method=FillToBorderMethod;
1636 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1643 if (LocaleCompare(keyword,"fill") == 0)
1645 (void) QueryColorDatabase(value,&draw_info->fill,
1649 if (LocaleCompare(keyword,"fuzz") == 0)
1651 msl_info->image[n]->fuzz=StringToDouble(value);
1654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1661 if (LocaleCompare(keyword,"geometry") == 0)
1663 flags=ParsePageGeometry(msl_info->image[n],value,
1664 &geometry,&exception);
1665 if ((flags & HeightValue) == 0)
1666 geometry.height=geometry.width;
1667 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1668 geometry.x,geometry.y,&target,&exception);
1671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1678 if (LocaleCompare(keyword,"x") == 0)
1680 geometry.x=StringToLong(value);
1681 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1682 geometry.x,geometry.y,&target,&exception);
1685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1692 if (LocaleCompare(keyword,"y") == 0)
1694 geometry.y=StringToLong(value);
1695 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1696 geometry.x,geometry.y,&target,&exception);
1699 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1711 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1712 draw_info,&target,geometry.x,geometry.y,
1713 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1714 draw_info=DestroyDrawInfo(draw_info);
1717 if (LocaleCompare((const char *) tag,"comment") == 0)
1719 if (LocaleCompare((const char *) tag,"composite") == 0)
1722 composite_geometry[MaxTextExtent];
1737 if (msl_info->image[n] == (Image *) NULL)
1739 ThrowMSLException(OptionError,"NoImagesDefined",
1740 (const char *) tag);
1743 composite_image=NewImageList();
1744 compose=OverCompositeOp;
1745 if (attributes != (const xmlChar **) NULL)
1746 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1748 keyword=(const char *) attributes[i++];
1749 attribute=InterpretImageProperties(msl_info->image_info[n],
1750 msl_info->attributes[n],(const char *) attributes[i]);
1751 CloneString(&value,attribute);
1757 if (LocaleCompare(keyword,"compose") == 0)
1759 option=ParseMagickOption(MagickComposeOptions,MagickFalse,
1762 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1764 compose=(CompositeOperator) option;
1772 if (LocaleCompare(keyword,"image") == 0)
1773 for (j=0; j < msl_info->n; j++)
1778 attribute=GetImageProperty(msl_info->attributes[j],"id");
1779 if ((attribute != (const char *) NULL) &&
1780 (LocaleCompare(attribute,value) == 0))
1782 composite_image=CloneImage(msl_info->image[j],0,0,
1783 MagickFalse,&exception);
1793 if (composite_image == (Image *) NULL)
1795 rotate_image=NewImageList();
1796 SetGeometry(msl_info->image[n],&geometry);
1797 if (attributes != (const xmlChar **) NULL)
1798 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1800 keyword=(const char *) attributes[i++];
1801 attribute=InterpretImageProperties(msl_info->image_info[n],
1802 msl_info->attributes[n],(const char *) attributes[i]);
1803 CloneString(&value,attribute);
1809 if (LocaleCompare(keyword,"blend") == 0)
1811 (void) SetImageArtifact(composite_image,
1812 "compose:args",value);
1815 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1822 if (LocaleCompare(keyword,"channel") == 0)
1824 option=ParseChannelOption(value);
1826 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1828 channel=(ChannelType) option;
1831 if (LocaleCompare(keyword, "color") == 0)
1833 (void) QueryColorDatabase(value,
1834 &composite_image->background_color,&exception);
1837 if (LocaleCompare(keyword,"compose") == 0)
1839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1846 if (LocaleCompare(keyword,"geometry") == 0)
1848 flags=ParsePageGeometry(msl_info->image[n],value,
1849 &geometry,&exception);
1850 if ((flags & HeightValue) == 0)
1851 geometry.height=geometry.width;
1852 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1853 geometry.y,&target,&exception);
1856 if (LocaleCompare(keyword,"gravity") == 0)
1858 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
1861 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1863 msl_info->image[n]->gravity=(GravityType) option;
1866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1873 if (LocaleCompare(keyword,"image") == 0)
1875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1882 if (LocaleCompare(keyword,"mask") == 0)
1883 for (j=0; j < msl_info->n; j++)
1888 attribute=GetImageProperty(msl_info->attributes[j],"id");
1889 if ((attribute != (const char *) NULL) &&
1890 (LocaleCompare(value,value) == 0))
1892 SetImageType(composite_image,TrueColorMatteType);
1893 (void) CompositeImage(composite_image,
1894 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"opacity") == 0)
1914 register PixelPacket
1920 opacity=QuantumRange-StringToLong(value);
1921 if (compose != DissolveCompositeOp)
1923 (void) SetImageOpacity(composite_image,(Quantum)
1927 (void) SetImageArtifact(msl_info->image[n],
1928 "compose:args",value);
1929 if (composite_image->matte != MagickTrue)
1930 (void) SetImageOpacity(composite_image,OpaqueOpacity);
1931 composite_view=AcquireCacheView(composite_image);
1932 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1934 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
1935 composite_image->columns,1,&exception);
1936 for (x=0; x < (ssize_t) composite_image->columns; x++)
1938 if (q->opacity == OpaqueOpacity)
1939 q->opacity=ClampToQuantum(opacity);
1942 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1945 composite_view=DestroyCacheView(composite_view);
1948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1955 if (LocaleCompare(keyword,"rotate") == 0)
1957 rotate_image=RotateImage(composite_image,StringToDouble(value),
1961 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1968 if (LocaleCompare(keyword,"tile") == 0)
1973 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
1976 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1978 tile=(MagickBooleanType) option;
1980 if (rotate_image != (Image *) NULL)
1981 (void) SetImageArtifact(rotate_image,
1982 "compose:outside-overlay","false");
1984 (void) SetImageArtifact(composite_image,
1985 "compose:outside-overlay","false");
1986 image=msl_info->image[n];
1987 height=composite_image->rows;
1988 width=composite_image->columns;
1989 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1990 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1992 if (rotate_image != (Image *) NULL)
1993 (void) CompositeImage(image,compose,rotate_image,
1996 (void) CompositeImage(image,compose,
1997 composite_image,x,y);
1999 if (rotate_image != (Image *) NULL)
2000 rotate_image=DestroyImage(rotate_image);
2003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2010 if (LocaleCompare(keyword,"x") == 0)
2012 geometry.x=StringToLong(value);
2013 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2014 geometry.y,&target,&exception);
2017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2024 if (LocaleCompare(keyword,"y") == 0)
2026 geometry.y=StringToLong(value);
2027 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2028 geometry.y,&target,&exception);
2031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2043 image=msl_info->image[n];
2044 (void) FormatMagickString(composite_geometry,MaxTextExtent,
2045 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2046 (double) composite_image->rows,(double) geometry.x,(double)
2048 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2050 if (rotate_image == (Image *) NULL)
2051 CompositeImageChannel(image,channel,compose,composite_image,
2052 geometry.x,geometry.y);
2058 geometry.x-=(ssize_t) (rotate_image->columns-
2059 composite_image->columns)/2;
2060 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2061 CompositeImageChannel(image,channel,compose,rotate_image,
2062 geometry.x,geometry.y);
2063 rotate_image=DestroyImage(rotate_image);
2065 composite_image=DestroyImage(composite_image);
2068 if (LocaleCompare((const char *) tag,"contrast") == 0)
2076 if (msl_info->image[n] == (Image *) NULL)
2078 ThrowMSLException(OptionError,"NoImagesDefined",
2079 (const char *) tag);
2082 sharpen=MagickFalse;
2083 if (attributes != (const xmlChar **) NULL)
2084 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2086 keyword=(const char *) attributes[i++];
2087 attribute=InterpretImageProperties(msl_info->image_info[n],
2088 msl_info->attributes[n],(const char *) attributes[i]);
2089 CloneString(&value,attribute);
2095 if (LocaleCompare(keyword,"sharpen") == 0)
2097 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2100 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2102 sharpen=(MagickBooleanType) option;
2105 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2117 (void) ContrastImage(msl_info->image[n],sharpen);
2120 if (LocaleCompare((const char *) tag,"crop") == 0)
2128 if (msl_info->image[n] == (Image *) NULL)
2130 ThrowMSLException(OptionError,"NoImagesDefined",
2131 (const char *) tag);
2134 SetGeometry(msl_info->image[n],&geometry);
2135 if (attributes != (const xmlChar **) NULL)
2136 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2138 keyword=(const char *) attributes[i++];
2139 attribute=InterpretImageProperties(msl_info->image_info[n],
2140 msl_info->attributes[n],(const char *) attributes[i]);
2141 CloneString(&value,attribute);
2147 if (LocaleCompare(keyword,"geometry") == 0)
2149 flags=ParsePageGeometry(msl_info->image[n],value,
2150 &geometry,&exception);
2151 if ((flags & HeightValue) == 0)
2152 geometry.height=geometry.width;
2155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2162 if (LocaleCompare(keyword,"height") == 0)
2164 geometry.height=StringToLong(value);
2167 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2174 if (LocaleCompare(keyword,"width") == 0)
2176 geometry.width=StringToLong(value);
2179 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2186 if (LocaleCompare(keyword,"x") == 0)
2188 geometry.x=StringToLong(value);
2191 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2198 if (LocaleCompare(keyword,"y") == 0)
2200 geometry.y=StringToLong(value);
2203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2215 crop_image=CropImage(msl_info->image[n],&geometry,
2216 &msl_info->image[n]->exception);
2217 if (crop_image == (Image *) NULL)
2219 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2220 msl_info->image[n]=crop_image;
2223 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2229 Cycle-colormap image.
2231 if (msl_info->image[n] == (Image *) NULL)
2233 ThrowMSLException(OptionError,"NoImagesDefined",
2234 (const char *) tag);
2238 if (attributes != (const xmlChar **) NULL)
2239 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2241 keyword=(const char *) attributes[i++];
2242 attribute=InterpretImageProperties(msl_info->image_info[n],
2243 msl_info->attributes[n],(const char *) attributes[i]);
2244 CloneString(&value,attribute);
2250 if (LocaleCompare(keyword,"display") == 0)
2252 display=StringToLong(value);
2255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2267 (void) CycleColormapImage(msl_info->image[n],display);
2270 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2275 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2283 if (msl_info->image[n] == (Image *) NULL)
2285 ThrowMSLException(OptionError,"NoImagesDefined",
2286 (const char *) tag);
2289 if (attributes != (const xmlChar **) NULL)
2290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2292 keyword=(const char *) attributes[i++];
2293 attribute=InterpretImageProperties(msl_info->image_info[n],
2294 msl_info->attributes[n],(const char *) attributes[i]);
2295 CloneString(&value,attribute);
2296 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2298 despeckle_image=DespeckleImage(msl_info->image[n],
2299 &msl_info->image[n]->exception);
2300 if (despeckle_image == (Image *) NULL)
2302 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2303 msl_info->image[n]=despeckle_image;
2306 if (LocaleCompare((const char *) tag,"display") == 0)
2308 if (msl_info->image[n] == (Image *) NULL)
2310 ThrowMSLException(OptionError,"NoImagesDefined",
2311 (const char *) tag);
2314 if (attributes != (const xmlChar **) NULL)
2315 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2317 keyword=(const char *) attributes[i++];
2318 attribute=InterpretImageProperties(msl_info->image_info[n],
2319 msl_info->attributes[n],(const char *) attributes[i]);
2320 CloneString(&value,attribute);
2325 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2331 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2334 if (LocaleCompare((const char *) tag,"draw") == 0)
2337 text[MaxTextExtent];
2342 if (msl_info->image[n] == (Image *) NULL)
2344 ThrowMSLException(OptionError,"NoImagesDefined",
2345 (const char *) tag);
2348 draw_info=CloneDrawInfo(msl_info->image_info[n],
2349 msl_info->draw_info[n]);
2351 current=draw_info->affine;
2352 GetAffineMatrix(&affine);
2353 if (attributes != (const xmlChar **) NULL)
2354 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2356 keyword=(const char *) attributes[i++];
2357 attribute=InterpretImageProperties(msl_info->image_info[n],
2358 msl_info->attributes[n],(const char *) attributes[i]);
2359 CloneString(&value,attribute);
2365 if (LocaleCompare(keyword,"affine") == 0)
2371 draw_info->affine.sx=strtod(p,&p);
2374 draw_info->affine.rx=strtod(p,&p);
2377 draw_info->affine.ry=strtod(p,&p);
2380 draw_info->affine.sy=strtod(p,&p);
2383 draw_info->affine.tx=strtod(p,&p);
2386 draw_info->affine.ty=strtod(p,&p);
2389 if (LocaleCompare(keyword,"align") == 0)
2391 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
2394 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2396 draw_info->align=(AlignType) option;
2399 if (LocaleCompare(keyword,"antialias") == 0)
2401 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2404 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2406 draw_info->stroke_antialias=(MagickBooleanType) option;
2407 draw_info->text_antialias=(MagickBooleanType) option;
2410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2417 if (LocaleCompare(keyword,"density") == 0)
2419 CloneString(&draw_info->density,value);
2422 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2429 if (LocaleCompare(keyword,"encoding") == 0)
2431 CloneString(&draw_info->encoding,value);
2434 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2441 if (LocaleCompare(keyword, "fill") == 0)
2443 (void) QueryColorDatabase(value,&draw_info->fill,
2447 if (LocaleCompare(keyword,"family") == 0)
2449 CloneString(&draw_info->family,value);
2452 if (LocaleCompare(keyword,"font") == 0)
2454 CloneString(&draw_info->font,value);
2457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2464 if (LocaleCompare(keyword,"geometry") == 0)
2466 flags=ParsePageGeometry(msl_info->image[n],value,
2467 &geometry,&exception);
2468 if ((flags & HeightValue) == 0)
2469 geometry.height=geometry.width;
2472 if (LocaleCompare(keyword,"gravity") == 0)
2474 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
2477 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2479 draw_info->gravity=(GravityType) option;
2482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2489 if (LocaleCompare(keyword,"primitive") == 0)
2491 CloneString(&draw_info->primitive,value);
2494 if (LocaleCompare(keyword,"pointsize") == 0)
2496 draw_info->pointsize=StringToDouble(value);
2499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2506 if (LocaleCompare(keyword,"rotate") == 0)
2508 angle=StringToDouble(value);
2509 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2510 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2511 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2512 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2522 if (LocaleCompare(keyword,"scale") == 0)
2524 flags=ParseGeometry(value,&geometry_info);
2525 if ((flags & SigmaValue) == 0)
2526 geometry_info.sigma=1.0;
2527 affine.sx=geometry_info.rho;
2528 affine.sy=geometry_info.sigma;
2531 if (LocaleCompare(keyword,"skewX") == 0)
2533 angle=StringToDouble(value);
2534 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2537 if (LocaleCompare(keyword,"skewY") == 0)
2539 angle=StringToDouble(value);
2540 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2543 if (LocaleCompare(keyword,"stretch") == 0)
2545 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
2548 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2550 draw_info->stretch=(StretchType) option;
2553 if (LocaleCompare(keyword, "stroke") == 0)
2555 (void) QueryColorDatabase(value,&draw_info->stroke,
2559 if (LocaleCompare(keyword,"strokewidth") == 0)
2561 draw_info->stroke_width=StringToLong(value);
2564 if (LocaleCompare(keyword,"style") == 0)
2566 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
2569 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2571 draw_info->style=(StyleType) option;
2574 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2581 if (LocaleCompare(keyword,"text") == 0)
2583 CloneString(&draw_info->text,value);
2586 if (LocaleCompare(keyword,"translate") == 0)
2588 flags=ParseGeometry(value,&geometry_info);
2589 if ((flags & SigmaValue) == 0)
2590 geometry_info.sigma=1.0;
2591 affine.tx=geometry_info.rho;
2592 affine.ty=geometry_info.sigma;
2595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2602 if (LocaleCompare(keyword, "undercolor") == 0)
2604 (void) QueryColorDatabase(value,&draw_info->undercolor,
2608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2615 if (LocaleCompare(keyword,"weight") == 0)
2617 draw_info->weight=StringToLong(value);
2620 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2627 if (LocaleCompare(keyword,"x") == 0)
2629 geometry.x=StringToLong(value);
2632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2639 if (LocaleCompare(keyword,"y") == 0)
2641 geometry.y=StringToLong(value);
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 (void) FormatMagickString(text,MaxTextExtent,
2657 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2658 geometry.height,(double) geometry.x,(double) geometry.y);
2659 CloneString(&draw_info->geometry,text);
2660 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2661 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2662 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2663 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2664 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2666 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2668 (void) DrawImage(msl_info->image[n],draw_info);
2669 draw_info=DestroyDrawInfo(draw_info);
2672 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2677 if (LocaleCompare((const char *) tag,"edge") == 0)
2685 if (msl_info->image[n] == (Image *) NULL)
2687 ThrowMSLException(OptionError,"NoImagesDefined",
2688 (const char *) tag);
2691 if (attributes != (const xmlChar **) NULL)
2692 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2694 keyword=(const char *) attributes[i++];
2695 attribute=InterpretImageProperties(msl_info->image_info[n],
2696 msl_info->attributes[n],(const char *) attributes[i]);
2697 CloneString(&value,attribute);
2703 if (LocaleCompare(keyword,"geometry") == 0)
2705 flags=ParseGeometry(value,&geometry_info);
2706 if ((flags & SigmaValue) == 0)
2707 geometry_info.sigma=1.0;
2710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2717 if (LocaleCompare(keyword,"radius") == 0)
2719 geometry_info.rho=StringToDouble(value);
2722 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2734 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2735 &msl_info->image[n]->exception);
2736 if (edge_image == (Image *) NULL)
2738 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2739 msl_info->image[n]=edge_image;
2742 if (LocaleCompare((const char *) tag,"emboss") == 0)
2750 if (msl_info->image[n] == (Image *) NULL)
2752 ThrowMSLException(OptionError,"NoImagesDefined",
2753 (const char *) tag);
2756 if (attributes != (const xmlChar **) NULL)
2757 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2759 keyword=(const char *) attributes[i++];
2760 attribute=InterpretImageProperties(msl_info->image_info[n],
2761 msl_info->attributes[n],(const char *) attributes[i]);
2762 CloneString(&value,attribute);
2768 if (LocaleCompare(keyword,"geometry") == 0)
2770 flags=ParseGeometry(value,&geometry_info);
2771 if ((flags & SigmaValue) == 0)
2772 geometry_info.sigma=1.0;
2775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2782 if (LocaleCompare(keyword,"radius") == 0)
2784 geometry_info.rho=StringToDouble(value);
2787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2794 if (LocaleCompare(keyword,"sigma") == 0)
2796 geometry_info.sigma=StringToLong(value);
2799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2805 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2811 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2812 geometry_info.sigma,&msl_info->image[n]->exception);
2813 if (emboss_image == (Image *) NULL)
2815 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2816 msl_info->image[n]=emboss_image;
2819 if (LocaleCompare((const char *) tag,"enhance") == 0)
2827 if (msl_info->image[n] == (Image *) NULL)
2829 ThrowMSLException(OptionError,"NoImagesDefined",
2830 (const char *) tag);
2833 if (attributes != (const xmlChar **) NULL)
2834 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2836 keyword=(const char *) attributes[i++];
2837 attribute=InterpretImageProperties(msl_info->image_info[n],
2838 msl_info->attributes[n],(const char *) attributes[i]);
2839 CloneString(&value,attribute);
2840 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2842 enhance_image=EnhanceImage(msl_info->image[n],
2843 &msl_info->image[n]->exception);
2844 if (enhance_image == (Image *) NULL)
2846 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2847 msl_info->image[n]=enhance_image;
2850 if (LocaleCompare((const char *) tag,"equalize") == 0)
2855 if (msl_info->image[n] == (Image *) NULL)
2857 ThrowMSLException(OptionError,"NoImagesDefined",
2858 (const char *) tag);
2861 if (attributes != (const xmlChar **) NULL)
2862 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2864 keyword=(const char *) attributes[i++];
2865 attribute=InterpretImageProperties(msl_info->image_info[n],
2866 msl_info->attributes[n],(const char *) attributes[i]);
2867 CloneString(&value,attribute);
2872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2878 (void) EqualizeImage(msl_info->image[n]);
2881 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2886 if (LocaleCompare((const char *) tag, "flatten") == 0)
2888 if (msl_info->image[n] == (Image *) NULL)
2890 ThrowMSLException(OptionError,"NoImagesDefined",
2891 (const char *) tag);
2895 /* no attributes here */
2897 /* process the image */
2902 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2903 &msl_info->image[n]->exception);
2904 if (newImage == (Image *) NULL)
2906 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2907 msl_info->image[n]=newImage;
2911 if (LocaleCompare((const char *) tag,"flip") == 0)
2919 if (msl_info->image[n] == (Image *) NULL)
2921 ThrowMSLException(OptionError,"NoImagesDefined",
2922 (const char *) tag);
2925 if (attributes != (const xmlChar **) NULL)
2926 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2928 keyword=(const char *) attributes[i++];
2929 attribute=InterpretImageProperties(msl_info->image_info[n],
2930 msl_info->attributes[n],(const char *) attributes[i]);
2931 CloneString(&value,attribute);
2932 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2934 flip_image=FlipImage(msl_info->image[n],
2935 &msl_info->image[n]->exception);
2936 if (flip_image == (Image *) NULL)
2938 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2939 msl_info->image[n]=flip_image;
2942 if (LocaleCompare((const char *) tag,"flop") == 0)
2950 if (msl_info->image[n] == (Image *) NULL)
2952 ThrowMSLException(OptionError,"NoImagesDefined",
2953 (const char *) tag);
2956 if (attributes != (const xmlChar **) NULL)
2957 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2959 keyword=(const char *) attributes[i++];
2960 attribute=InterpretImageProperties(msl_info->image_info[n],
2961 msl_info->attributes[n],(const char *) attributes[i]);
2962 CloneString(&value,attribute);
2963 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2965 flop_image=FlopImage(msl_info->image[n],
2966 &msl_info->image[n]->exception);
2967 if (flop_image == (Image *) NULL)
2969 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2970 msl_info->image[n]=flop_image;
2973 if (LocaleCompare((const char *) tag,"frame") == 0)
2984 if (msl_info->image[n] == (Image *) NULL)
2986 ThrowMSLException(OptionError,"NoImagesDefined",
2987 (const char *) tag);
2990 SetGeometry(msl_info->image[n],&geometry);
2991 if (attributes != (const xmlChar **) NULL)
2992 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2994 keyword=(const char *) attributes[i++];
2995 attribute=InterpretImageProperties(msl_info->image_info[n],
2996 msl_info->attributes[n],(const char *) attributes[i]);
2997 CloneString(&value,attribute);
3003 if (LocaleCompare(keyword,"compose") == 0)
3005 option=ParseMagickOption(MagickComposeOptions,
3008 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3010 msl_info->image[n]->compose=(CompositeOperator) option;
3013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3020 if (LocaleCompare(keyword, "fill") == 0)
3022 (void) QueryColorDatabase(value,
3023 &msl_info->image[n]->matte_color,&exception);
3026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3033 if (LocaleCompare(keyword,"geometry") == 0)
3035 flags=ParsePageGeometry(msl_info->image[n],value,
3036 &geometry,&exception);
3037 if ((flags & HeightValue) == 0)
3038 geometry.height=geometry.width;
3039 frame_info.width=geometry.width;
3040 frame_info.height=geometry.height;
3041 frame_info.outer_bevel=geometry.x;
3042 frame_info.inner_bevel=geometry.y;
3045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3052 if (LocaleCompare(keyword,"height") == 0)
3054 frame_info.height=StringToLong(value);
3057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3064 if (LocaleCompare(keyword,"inner") == 0)
3066 frame_info.inner_bevel=StringToLong(value);
3069 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3076 if (LocaleCompare(keyword,"outer") == 0)
3078 frame_info.outer_bevel=StringToLong(value);
3081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3088 if (LocaleCompare(keyword,"width") == 0)
3090 frame_info.width=StringToLong(value);
3093 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3105 frame_info.x=(ssize_t) frame_info.width;
3106 frame_info.y=(ssize_t) frame_info.height;
3107 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3108 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3109 frame_image=FrameImage(msl_info->image[n],&frame_info,
3110 &msl_info->image[n]->exception);
3111 if (frame_image == (Image *) NULL)
3113 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3114 msl_info->image[n]=frame_image;
3117 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3122 if (LocaleCompare((const char *) tag,"gamma") == 0)
3125 gamma[MaxTextExtent];
3133 if (msl_info->image[n] == (Image *) NULL)
3135 ThrowMSLException(OptionError,"NoImagesDefined",
3136 (const char *) tag);
3139 channel=UndefinedChannel;
3144 if (attributes != (const xmlChar **) NULL)
3145 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3147 keyword=(const char *) attributes[i++];
3148 attribute=InterpretImageProperties(msl_info->image_info[n],
3149 msl_info->attributes[n],(const char *) attributes[i]);
3150 CloneString(&value,attribute);
3156 if (LocaleCompare(keyword,"blue") == 0)
3158 pixel.blue=StringToDouble(value);
3161 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3168 if (LocaleCompare(keyword,"channel") == 0)
3170 option=ParseChannelOption(value);
3172 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3174 channel=(ChannelType) option;
3177 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3184 if (LocaleCompare(keyword,"gamma") == 0)
3186 (void) CopyMagickString(gamma,value,MaxTextExtent);
3189 if (LocaleCompare(keyword,"green") == 0)
3191 pixel.green=StringToDouble(value);
3194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3201 if (LocaleCompare(keyword,"red") == 0)
3203 pixel.red=StringToDouble(value);
3206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3212 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3219 (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
3220 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3225 (void) GammaImage(msl_info->image[n],gamma);
3230 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3235 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3241 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3248 else if (LocaleCompare((const char *) tag,"get") == 0)
3250 if (msl_info->image[n] == (Image *) NULL)
3252 ThrowMSLException(OptionError,"NoImagesDefined",
3253 (const char *) tag);
3256 if (attributes == (const xmlChar **) NULL)
3258 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3260 keyword=(const char *) attributes[i++];
3261 CloneString(&value,(const char *) attributes[i]);
3262 (void) CopyMagickString(key,value,MaxTextExtent);
3268 if (LocaleCompare(keyword,"height") == 0)
3270 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3271 (double) msl_info->image[n]->rows);
3272 (void) SetImageProperty(msl_info->attributes[n],key,value);
3275 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3280 if (LocaleCompare(keyword,"width") == 0)
3282 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3283 (double) msl_info->image[n]->columns);
3284 (void) SetImageProperty(msl_info->attributes[n],key,value);
3287 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3291 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3298 else if (LocaleCompare((const char *) tag, "group") == 0)
3300 msl_info->number_groups++;
3301 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3302 msl_info->group_info,msl_info->number_groups+1UL,
3303 sizeof(*msl_info->group_info));
3306 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3311 if (LocaleCompare((const char *) tag,"image") == 0)
3313 MSLPushImage(msl_info,(Image *) NULL);
3314 if (attributes == (const xmlChar **) NULL)
3316 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3318 keyword=(const char *) attributes[i++];
3319 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3320 msl_info->attributes[n],(const char *) attributes[i]));
3326 if (LocaleCompare(keyword,"color") == 0)
3331 (void) CopyMagickString(msl_info->image_info[n]->filename,
3332 "xc:",MaxTextExtent);
3333 (void) ConcatenateMagickString(msl_info->image_info[n]->
3334 filename,value,MaxTextExtent);
3335 next_image=ReadImage(msl_info->image_info[n],&exception);
3336 CatchException(&exception);
3337 if (next_image == (Image *) NULL)
3339 if (msl_info->image[n] == (Image *) NULL)
3340 msl_info->image[n]=next_image;
3347 Link image into image list.
3349 p=msl_info->image[n];
3350 while (p->next != (Image *) NULL)
3351 p=GetNextImageInList(p);
3352 next_image->previous=p;
3357 (void) SetMSLAttributes(msl_info,keyword,value);
3362 (void) SetMSLAttributes(msl_info,keyword,value);
3369 if (LocaleCompare((const char *) tag,"implode") == 0)
3377 if (msl_info->image[n] == (Image *) NULL)
3379 ThrowMSLException(OptionError,"NoImagesDefined",
3380 (const char *) tag);
3383 if (attributes != (const xmlChar **) NULL)
3384 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3386 keyword=(const char *) attributes[i++];
3387 attribute=InterpretImageProperties(msl_info->image_info[n],
3388 msl_info->attributes[n],(const char *) attributes[i]);
3389 CloneString(&value,attribute);
3395 if (LocaleCompare(keyword,"amount") == 0)
3397 geometry_info.rho=StringToDouble(value);
3400 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3407 if (LocaleCompare(keyword,"geometry") == 0)
3409 flags=ParseGeometry(value,&geometry_info);
3410 if ((flags & SigmaValue) == 0)
3411 geometry_info.sigma=1.0;
3414 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3426 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3427 &msl_info->image[n]->exception);
3428 if (implode_image == (Image *) NULL)
3430 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3431 msl_info->image[n]=implode_image;
3434 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3439 if (LocaleCompare((const char *) tag,"label") == 0)
3441 if (LocaleCompare((const char *) tag, "level") == 0)
3444 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3446 if (msl_info->image[n] == (Image *) NULL)
3448 ThrowMSLException(OptionError,"NoImagesDefined",
3449 (const char *) tag);
3452 if (attributes == (const xmlChar **) NULL)
3454 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3456 keyword=(const char *) attributes[i++];
3457 CloneString(&value,(const char *) attributes[i]);
3458 (void) CopyMagickString(key,value,MaxTextExtent);
3464 if (LocaleCompare(keyword,"black") == 0)
3466 levelBlack = StringToDouble( value );
3469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3475 if (LocaleCompare(keyword,"gamma") == 0)
3477 levelGamma = StringToDouble( value );
3480 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3486 if (LocaleCompare(keyword,"white") == 0)
3488 levelWhite = StringToDouble( value );
3491 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3496 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3504 char level[MaxTextExtent + 1];
3505 (void) FormatMagickString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3506 levelBlack,levelGamma,levelWhite);
3507 LevelImage ( msl_info->image[n], level );
3515 if (LocaleCompare((const char *) tag,"magnify") == 0)
3523 if (msl_info->image[n] == (Image *) NULL)
3525 ThrowMSLException(OptionError,"NoImagesDefined",
3526 (const char *) tag);
3529 if (attributes != (const xmlChar **) NULL)
3530 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3532 keyword=(const char *) attributes[i++];
3533 attribute=InterpretImageProperties(msl_info->image_info[n],
3534 msl_info->attributes[n],(const char *) attributes[i]);
3535 CloneString(&value,attribute);
3536 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3538 magnify_image=MagnifyImage(msl_info->image[n],
3539 &msl_info->image[n]->exception);
3540 if (magnify_image == (Image *) NULL)
3542 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3543 msl_info->image[n]=magnify_image;
3546 if (LocaleCompare((const char *) tag,"map") == 0)
3560 if (msl_info->image[n] == (Image *) NULL)
3562 ThrowMSLException(OptionError,"NoImagesDefined",
3563 (const char *) tag);
3566 affinity_image=NewImageList();
3568 if (attributes != (const xmlChar **) NULL)
3569 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3571 keyword=(const char *) attributes[i++];
3572 attribute=InterpretImageProperties(msl_info->image_info[n],
3573 msl_info->attributes[n],(const char *) attributes[i]);
3574 CloneString(&value,attribute);
3580 if (LocaleCompare(keyword,"dither") == 0)
3582 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
3585 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3587 dither=(MagickBooleanType) option;
3590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3597 if (LocaleCompare(keyword,"image") == 0)
3598 for (j=0; j < msl_info->n; j++)
3603 attribute=GetImageProperty(msl_info->attributes[j],"id");
3604 if ((attribute != (const char *) NULL) &&
3605 (LocaleCompare(attribute,value) == 0))
3607 affinity_image=CloneImage(msl_info->image[j],0,0,
3608 MagickFalse,&exception);
3616 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3622 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3623 quantize_info->dither=dither;
3624 (void) RemapImages(quantize_info,msl_info->image[n],
3626 quantize_info=DestroyQuantizeInfo(quantize_info);
3627 affinity_image=DestroyImage(affinity_image);
3630 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3642 Matte floodfill image.
3645 if (msl_info->image[n] == (Image *) NULL)
3647 ThrowMSLException(OptionError,"NoImagesDefined",
3648 (const char *) tag);
3651 SetGeometry(msl_info->image[n],&geometry);
3652 paint_method=FloodfillMethod;
3653 if (attributes != (const xmlChar **) NULL)
3654 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3656 keyword=(const char *) attributes[i++];
3657 attribute=InterpretImageProperties(msl_info->image_info[n],
3658 msl_info->attributes[n],(const char *) attributes[i]);
3659 CloneString(&value,attribute);
3665 if (LocaleCompare(keyword,"bordercolor") == 0)
3667 (void) QueryMagickColor(value,&target,&exception);
3668 paint_method=FillToBorderMethod;
3671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3678 if (LocaleCompare(keyword,"fuzz") == 0)
3680 msl_info->image[n]->fuzz=StringToDouble(value);
3683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3690 if (LocaleCompare(keyword,"geometry") == 0)
3692 flags=ParsePageGeometry(msl_info->image[n],value,
3693 &geometry,&exception);
3694 if ((flags & HeightValue) == 0)
3695 geometry.height=geometry.width;
3696 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3697 geometry.x,geometry.y,&target,&exception);
3700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3707 if (LocaleCompare(keyword,"opacity") == 0)
3709 opacity=StringToDouble(value);
3712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3719 if (LocaleCompare(keyword,"x") == 0)
3721 geometry.x=StringToLong(value);
3722 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3723 geometry.x,geometry.y,&target,&exception);
3726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3733 if (LocaleCompare(keyword,"y") == 0)
3735 geometry.y=StringToLong(value);
3736 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3737 geometry.x,geometry.y,&target,&exception);
3740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3752 draw_info=CloneDrawInfo(msl_info->image_info[n],
3753 msl_info->draw_info[n]);
3754 draw_info->fill.opacity=ClampToQuantum(opacity);
3755 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3756 draw_info,&target,geometry.x,geometry.y,
3757 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3758 draw_info=DestroyDrawInfo(draw_info);
3761 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3767 Median-filter image.
3769 if (msl_info->image[n] == (Image *) NULL)
3771 ThrowMSLException(OptionError,"NoImagesDefined",
3772 (const char *) tag);
3775 if (attributes != (const xmlChar **) NULL)
3776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3778 keyword=(const char *) attributes[i++];
3779 attribute=InterpretImageProperties(msl_info->image_info[n],
3780 msl_info->attributes[n],(const char *) attributes[i]);
3781 CloneString(&value,attribute);
3787 if (LocaleCompare(keyword,"geometry") == 0)
3789 flags=ParseGeometry(value,&geometry_info);
3790 if ((flags & SigmaValue) == 0)
3791 geometry_info.sigma=1.0;
3794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3801 if (LocaleCompare(keyword,"radius") == 0)
3803 geometry_info.rho=StringToDouble(value);
3806 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3818 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3819 geometry_info.rho,&msl_info->image[n]->exception);
3820 if (median_image == (Image *) NULL)
3822 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3823 msl_info->image[n]=median_image;
3826 if (LocaleCompare((const char *) tag,"minify") == 0)
3834 if (msl_info->image[n] == (Image *) NULL)
3836 ThrowMSLException(OptionError,"NoImagesDefined",
3837 (const char *) tag);
3840 if (attributes != (const xmlChar **) NULL)
3841 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3843 keyword=(const char *) attributes[i++];
3844 attribute=InterpretImageProperties(msl_info->image_info[n],
3845 msl_info->attributes[n],(const char *) attributes[i]);
3846 CloneString(&value,attribute);
3847 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3849 minify_image=MinifyImage(msl_info->image[n],
3850 &msl_info->image[n]->exception);
3851 if (minify_image == (Image *) NULL)
3853 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3854 msl_info->image[n]=minify_image;
3857 if (LocaleCompare((const char *) tag,"msl") == 0 )
3859 if (LocaleCompare((const char *) tag,"modulate") == 0)
3862 modulate[MaxTextExtent];
3867 if (msl_info->image[n] == (Image *) NULL)
3869 ThrowMSLException(OptionError,"NoImagesDefined",
3870 (const char *) tag);
3873 geometry_info.rho=100.0;
3874 geometry_info.sigma=100.0;
3875 geometry_info.xi=100.0;
3876 if (attributes != (const xmlChar **) NULL)
3877 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3879 keyword=(const char *) attributes[i++];
3880 attribute=InterpretImageProperties(msl_info->image_info[n],
3881 msl_info->attributes[n],(const char *) attributes[i]);
3882 CloneString(&value,attribute);
3888 if (LocaleCompare(keyword,"blackness") == 0)
3890 geometry_info.rho=StringToDouble(value);
3893 if (LocaleCompare(keyword,"brightness") == 0)
3895 geometry_info.rho=StringToDouble(value);
3898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3905 if (LocaleCompare(keyword,"factor") == 0)
3907 flags=ParseGeometry(value,&geometry_info);
3910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3917 if (LocaleCompare(keyword,"hue") == 0)
3919 geometry_info.xi=StringToDouble(value);
3922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3929 if (LocaleCompare(keyword,"lightness") == 0)
3931 geometry_info.rho=StringToDouble(value);
3934 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3941 if (LocaleCompare(keyword,"saturation") == 0)
3943 geometry_info.sigma=StringToDouble(value);
3946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3953 if (LocaleCompare(keyword,"whiteness") == 0)
3955 geometry_info.sigma=StringToDouble(value);
3958 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3964 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3970 (void) FormatMagickString(modulate,MaxTextExtent,"%g,%g,%g",
3971 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3972 (void) ModulateImage(msl_info->image[n],modulate);
3975 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3980 if (LocaleCompare((const char *) tag,"negate") == 0)
3988 if (msl_info->image[n] == (Image *) NULL)
3990 ThrowMSLException(OptionError,"NoImagesDefined",
3991 (const char *) tag);
3995 if (attributes != (const xmlChar **) NULL)
3996 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3998 keyword=(const char *) attributes[i++];
3999 attribute=InterpretImageProperties(msl_info->image_info[n],
4000 msl_info->attributes[n],(const char *) attributes[i]);
4001 CloneString(&value,attribute);
4007 if (LocaleCompare(keyword,"channel") == 0)
4009 option=ParseChannelOption(value);
4011 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4013 channel=(ChannelType) option;
4016 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4023 if (LocaleCompare(keyword,"gray") == 0)
4025 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4028 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4030 gray=(MagickBooleanType) option;
4033 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4045 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4048 if (LocaleCompare((const char *) tag,"normalize") == 0)
4053 if (msl_info->image[n] == (Image *) NULL)
4055 ThrowMSLException(OptionError,"NoImagesDefined",
4056 (const char *) tag);
4059 if (attributes != (const xmlChar **) NULL)
4060 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4062 keyword=(const char *) attributes[i++];
4063 attribute=InterpretImageProperties(msl_info->image_info[n],
4064 msl_info->attributes[n],(const char *) attributes[i]);
4065 CloneString(&value,attribute);
4071 if (LocaleCompare(keyword,"channel") == 0)
4073 option=ParseChannelOption(value);
4075 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4077 channel=(ChannelType) option;
4080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4086 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4092 (void) NormalizeImageChannel(msl_info->image[n],channel);
4095 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4100 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4108 if (msl_info->image[n] == (Image *) NULL)
4110 ThrowMSLException(OptionError,"NoImagesDefined",
4111 (const char *) tag);
4114 if (attributes != (const xmlChar **) NULL)
4115 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4117 keyword=(const char *) attributes[i++];
4118 attribute=InterpretImageProperties(msl_info->image_info[n],
4119 msl_info->attributes[n],(const char *) attributes[i]);
4120 CloneString(&value,attribute);
4126 if (LocaleCompare(keyword,"geometry") == 0)
4128 flags=ParseGeometry(value,&geometry_info);
4129 if ((flags & SigmaValue) == 0)
4130 geometry_info.sigma=1.0;
4133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4140 if (LocaleCompare(keyword,"radius") == 0)
4142 geometry_info.rho=StringToDouble(value);
4145 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4151 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4157 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4158 &msl_info->image[n]->exception);
4159 if (paint_image == (Image *) NULL)
4161 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4162 msl_info->image[n]=paint_image;
4165 if (LocaleCompare((const char *) tag,"opaque") == 0)
4174 if (msl_info->image[n] == (Image *) NULL)
4176 ThrowMSLException(OptionError,"NoImagesDefined",
4177 (const char *) tag);
4180 (void) QueryMagickColor("none",&target,&exception);
4181 (void) QueryMagickColor("none",&fill_color,&exception);
4182 if (attributes != (const xmlChar **) NULL)
4183 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4185 keyword=(const char *) attributes[i++];
4186 attribute=InterpretImageProperties(msl_info->image_info[n],
4187 msl_info->attributes[n],(const char *) attributes[i]);
4188 CloneString(&value,attribute);
4194 if (LocaleCompare(keyword,"channel") == 0)
4196 option=ParseChannelOption(value);
4198 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4200 channel=(ChannelType) option;
4203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4210 if (LocaleCompare(keyword,"fill") == 0)
4212 (void) QueryMagickColor(value,&fill_color,&exception);
4215 if (LocaleCompare(keyword,"fuzz") == 0)
4217 msl_info->image[n]->fuzz=StringToDouble(value);
4220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4232 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4233 &target,&fill_color,MagickFalse);
4236 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4241 if (LocaleCompare((const char *) tag,"print") == 0)
4243 if (attributes == (const xmlChar **) NULL)
4245 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4247 keyword=(const char *) attributes[i++];
4248 attribute=InterpretImageProperties(msl_info->image_info[n],
4249 msl_info->attributes[n],(const char *) attributes[i]);
4250 CloneString(&value,attribute);
4256 if (LocaleCompare(keyword,"output") == 0)
4258 (void) fprintf(stdout,"%s",value);
4261 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4266 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4273 if (LocaleCompare((const char *) tag, "profile") == 0)
4275 if (msl_info->image[n] == (Image *) NULL)
4277 ThrowMSLException(OptionError,"NoImagesDefined",
4278 (const char *) tag);
4281 if (attributes == (const xmlChar **) NULL)
4283 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4297 keyword=(const char *) attributes[i++];
4298 attribute=InterpretImageProperties(msl_info->image_info[n],
4299 msl_info->attributes[n],(const char *) attributes[i]);
4300 CloneString(&value,attribute);
4301 if (*keyword == '+')
4304 Remove a profile from the image.
4306 (void) ProfileImage(msl_info->image[n],keyword,
4307 (const unsigned char *) NULL,0,MagickTrue);
4311 Associate a profile with the image.
4313 profile_info=CloneImageInfo(msl_info->image_info[n]);
4314 profile=GetImageProfile(msl_info->image[n],"iptc");
4315 if (profile != (StringInfo *) NULL)
4316 profile_info->profile=(void *) CloneStringInfo(profile);
4317 profile_image=GetImageCache(profile_info,keyword,&exception);
4318 profile_info=DestroyImageInfo(profile_info);
4319 if (profile_image == (Image *) NULL)
4322 name[MaxTextExtent],
4323 filename[MaxTextExtent];
4331 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4332 (void) CopyMagickString(name,keyword,MaxTextExtent);
4333 for (p=filename; *p != '\0'; p++)
4334 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4335 (IsPathAccessible(keyword) == MagickFalse))
4341 Look for profile name (e.g. name:profile).
4343 (void) CopyMagickString(name,filename,(size_t)
4345 for (q=filename; *q != '\0'; q++)
4349 profile=FileToStringInfo(filename,~0UL,&exception);
4350 if (profile != (StringInfo *) NULL)
4352 (void) ProfileImage(msl_info->image[n],name,
4353 GetStringInfoDatum(profile),(size_t)
4354 GetStringInfoLength(profile),MagickFalse);
4355 profile=DestroyStringInfo(profile);
4359 ResetImageProfileIterator(profile_image);
4360 name=GetNextImageProfile(profile_image);
4361 while (name != (const char *) NULL)
4363 profile=GetImageProfile(profile_image,name);
4364 if (profile != (StringInfo *) NULL)
4365 (void) ProfileImage(msl_info->image[n],name,
4366 GetStringInfoDatum(profile),(size_t)
4367 GetStringInfoLength(profile),MagickFalse);
4368 name=GetNextImageProfile(profile_image);
4370 profile_image=DestroyImage(profile_image);
4374 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4379 if (LocaleCompare((const char *) tag,"quantize") == 0)
4387 if (msl_info->image[n] == (Image *) NULL)
4389 ThrowMSLException(OptionError,"NoImagesDefined",
4390 (const char *) tag);
4393 GetQuantizeInfo(&quantize_info);
4394 if (attributes != (const xmlChar **) NULL)
4395 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4397 keyword=(const char *) attributes[i++];
4398 attribute=InterpretImageProperties(msl_info->image_info[n],
4399 msl_info->attributes[n],(const char *) attributes[i]);
4400 CloneString(&value,attribute);
4406 if (LocaleCompare(keyword,"colors") == 0)
4408 quantize_info.number_colors=StringToLong(value);
4411 if (LocaleCompare(keyword,"colorspace") == 0)
4413 option=ParseMagickOption(MagickColorspaceOptions,
4416 ThrowMSLException(OptionError,
4417 "UnrecognizedColorspaceType",value);
4418 quantize_info.colorspace=(ColorspaceType) option;
4421 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4428 if (LocaleCompare(keyword,"dither") == 0)
4430 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4433 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4435 quantize_info.dither=(MagickBooleanType) option;
4438 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4445 if (LocaleCompare(keyword,"measure") == 0)
4447 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4450 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4452 quantize_info.measure_error=(MagickBooleanType) option;
4455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4462 if (LocaleCompare(keyword,"treedepth") == 0)
4464 quantize_info.tree_depth=StringToLong(value);
4467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4473 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4479 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4482 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4485 text[MaxTextExtent];
4496 draw_info=CloneDrawInfo(msl_info->image_info[n],
4497 msl_info->draw_info[n]);
4499 current=draw_info->affine;
4500 GetAffineMatrix(&affine);
4501 if (attributes != (const xmlChar **) NULL)
4502 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4504 keyword=(const char *) attributes[i++];
4505 attribute=InterpretImageProperties(msl_info->image_info[n],
4506 msl_info->attributes[n],(const char *) attributes[i]);
4507 CloneString(&value,attribute);
4513 if (LocaleCompare(keyword,"affine") == 0)
4519 draw_info->affine.sx=strtod(p,&p);
4522 draw_info->affine.rx=strtod(p,&p);
4525 draw_info->affine.ry=strtod(p,&p);
4528 draw_info->affine.sy=strtod(p,&p);
4531 draw_info->affine.tx=strtod(p,&p);
4534 draw_info->affine.ty=strtod(p,&p);
4537 if (LocaleCompare(keyword,"align") == 0)
4539 option=ParseMagickOption(MagickAlignOptions,MagickFalse,
4542 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4544 draw_info->align=(AlignType) option;
4547 if (LocaleCompare(keyword,"antialias") == 0)
4549 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4552 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4554 draw_info->stroke_antialias=(MagickBooleanType) option;
4555 draw_info->text_antialias=(MagickBooleanType) option;
4558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4565 if (LocaleCompare(keyword,"density") == 0)
4567 CloneString(&draw_info->density,value);
4570 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4577 if (LocaleCompare(keyword,"encoding") == 0)
4579 CloneString(&draw_info->encoding,value);
4582 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4589 if (LocaleCompare(keyword, "fill") == 0)
4591 (void) QueryColorDatabase(value,&draw_info->fill,
4595 if (LocaleCompare(keyword,"family") == 0)
4597 CloneString(&draw_info->family,value);
4600 if (LocaleCompare(keyword,"font") == 0)
4602 CloneString(&draw_info->font,value);
4605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4612 if (LocaleCompare(keyword,"geometry") == 0)
4614 flags=ParsePageGeometry(msl_info->image[n],value,
4615 &geometry,&exception);
4616 if ((flags & HeightValue) == 0)
4617 geometry.height=geometry.width;
4620 if (LocaleCompare(keyword,"gravity") == 0)
4622 option=ParseMagickOption(MagickGravityOptions,MagickFalse,
4625 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4627 draw_info->gravity=(GravityType) option;
4630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4637 if (LocaleCompare(keyword,"pointsize") == 0)
4639 draw_info->pointsize=StringToDouble(value);
4642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4649 if (LocaleCompare(keyword,"rotate") == 0)
4651 angle=StringToDouble(value);
4652 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4653 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4654 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4655 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4665 if (LocaleCompare(keyword,"scale") == 0)
4667 flags=ParseGeometry(value,&geometry_info);
4668 if ((flags & SigmaValue) == 0)
4669 geometry_info.sigma=1.0;
4670 affine.sx=geometry_info.rho;
4671 affine.sy=geometry_info.sigma;
4674 if (LocaleCompare(keyword,"skewX") == 0)
4676 angle=StringToDouble(value);
4677 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4680 if (LocaleCompare(keyword,"skewY") == 0)
4682 angle=StringToDouble(value);
4683 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4686 if (LocaleCompare(keyword,"stretch") == 0)
4688 option=ParseMagickOption(MagickStretchOptions,MagickFalse,
4691 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4693 draw_info->stretch=(StretchType) option;
4696 if (LocaleCompare(keyword, "stroke") == 0)
4698 (void) QueryColorDatabase(value,&draw_info->stroke,
4702 if (LocaleCompare(keyword,"strokewidth") == 0)
4704 draw_info->stroke_width=StringToLong(value);
4707 if (LocaleCompare(keyword,"style") == 0)
4709 option=ParseMagickOption(MagickStyleOptions,MagickFalse,
4712 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4714 draw_info->style=(StyleType) option;
4717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4724 if (LocaleCompare(keyword,"text") == 0)
4726 CloneString(&draw_info->text,value);
4729 if (LocaleCompare(keyword,"translate") == 0)
4731 flags=ParseGeometry(value,&geometry_info);
4732 if ((flags & SigmaValue) == 0)
4733 geometry_info.sigma=1.0;
4734 affine.tx=geometry_info.rho;
4735 affine.ty=geometry_info.sigma;
4738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4745 if (LocaleCompare(keyword, "undercolor") == 0)
4747 (void) QueryColorDatabase(value,&draw_info->undercolor,
4751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4758 if (LocaleCompare(keyword,"weight") == 0)
4760 draw_info->weight=StringToLong(value);
4763 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4770 if (LocaleCompare(keyword,"x") == 0)
4772 geometry.x=StringToLong(value);
4775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4782 if (LocaleCompare(keyword,"y") == 0)
4784 geometry.y=StringToLong(value);
4787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4793 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4799 (void) FormatMagickString(text,MaxTextExtent,
4800 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4801 geometry.height,(double) geometry.x,(double) geometry.y);
4802 CloneString(&draw_info->geometry,text);
4803 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4804 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4805 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4806 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4807 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4809 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4811 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4812 if (status != MagickFalse)
4817 image=msl_info->attributes[n];
4818 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4819 "%g",metrics.pixels_per_em.x);
4820 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4821 "%g",metrics.pixels_per_em.y);
4822 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4824 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4826 FormatImageProperty(image,"msl:font-metrics.width","%g",
4828 FormatImageProperty(image,"msl:font-metrics.height","%g",
4830 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4831 metrics.max_advance);
4832 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4834 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4836 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4838 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4840 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4842 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4845 draw_info=DestroyDrawInfo(draw_info);
4848 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4853 if (LocaleCompare((const char *) tag,"raise") == 0)
4861 if (msl_info->image[n] == (Image *) NULL)
4863 ThrowMSLException(OptionError,"NoImagesDefined",
4864 (const char *) tag);
4868 SetGeometry(msl_info->image[n],&geometry);
4869 if (attributes != (const xmlChar **) NULL)
4870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4872 keyword=(const char *) attributes[i++];
4873 attribute=InterpretImageProperties(msl_info->image_info[n],
4874 msl_info->attributes[n],(const char *) attributes[i]);
4875 CloneString(&value,attribute);
4881 if (LocaleCompare(keyword,"geometry") == 0)
4883 flags=ParsePageGeometry(msl_info->image[n],value,
4884 &geometry,&exception);
4885 if ((flags & HeightValue) == 0)
4886 geometry.height=geometry.width;
4889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4896 if (LocaleCompare(keyword,"height") == 0)
4898 geometry.height=StringToLong(value);
4901 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4908 if (LocaleCompare(keyword,"raise") == 0)
4910 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
4913 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4915 raise=(MagickBooleanType) option;
4918 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4925 if (LocaleCompare(keyword,"width") == 0)
4927 geometry.width=StringToLong(value);
4930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4942 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4945 if (LocaleCompare((const char *) tag,"read") == 0)
4947 if (attributes == (const xmlChar **) NULL)
4949 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4951 keyword=(const char *) attributes[i++];
4952 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4953 msl_info->attributes[n],(const char *) attributes[i]));
4959 if (LocaleCompare(keyword,"filename") == 0)
4964 (void) CopyMagickString(msl_info->image_info[n]->filename,
4965 value,MaxTextExtent);
4966 image=ReadImage(msl_info->image_info[n],&exception);
4967 CatchException(&exception);
4968 if (image == (Image *) NULL)
4970 AppendImageToList(&msl_info->image[n],image);
4973 (void) SetMSLAttributes(msl_info,keyword,value);
4978 (void) SetMSLAttributes(msl_info,keyword,value);
4985 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4993 if (msl_info->image[n] == (Image *) NULL)
4995 ThrowMSLException(OptionError,"NoImagesDefined",
4996 (const char *) tag);
4999 if (attributes != (const xmlChar **) NULL)
5000 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5002 keyword=(const char *) attributes[i++];
5003 attribute=InterpretImageProperties(msl_info->image_info[n],
5004 msl_info->attributes[n],(const char *) attributes[i]);
5005 CloneString(&value,attribute);
5011 if (LocaleCompare(keyword,"geometry") == 0)
5013 flags=ParseGeometry(value,&geometry_info);
5014 if ((flags & SigmaValue) == 0)
5015 geometry_info.sigma=1.0;
5018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5025 if (LocaleCompare(keyword,"radius") == 0)
5027 geometry_info.rho=StringToDouble(value);
5030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5042 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5043 geometry_info.rho,&msl_info->image[n]->exception);
5044 if (paint_image == (Image *) NULL)
5046 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5047 msl_info->image[n]=paint_image;
5050 else if (LocaleCompare((const char *) tag,"repage") == 0)
5052 /* init the values */
5053 width=msl_info->image[n]->page.width;
5054 height=msl_info->image[n]->page.height;
5055 x=msl_info->image[n]->page.x;
5056 y=msl_info->image[n]->page.y;
5058 if (msl_info->image[n] == (Image *) NULL)
5060 ThrowMSLException(OptionError,"NoImagesDefined",
5061 (const char *) tag);
5064 if (attributes == (const xmlChar **) NULL)
5066 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5068 keyword=(const char *) attributes[i++];
5069 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5070 msl_info->attributes[n],(const char *) attributes[i]));
5076 if (LocaleCompare(keyword,"geometry") == 0)
5084 flags=ParseAbsoluteGeometry(value,&geometry);
5085 if ((flags & WidthValue) != 0)
5087 if ((flags & HeightValue) == 0)
5088 geometry.height=geometry.width;
5089 width=geometry.width;
5090 height=geometry.height;
5092 if ((flags & AspectValue) != 0)
5094 if ((flags & XValue) != 0)
5096 if ((flags & YValue) != 0)
5101 if ((flags & XValue) != 0)
5104 if ((width == 0) && (geometry.x > 0))
5105 width=msl_info->image[n]->columns+geometry.x;
5107 if ((flags & YValue) != 0)
5110 if ((height == 0) && (geometry.y > 0))
5111 height=msl_info->image[n]->rows+geometry.y;
5116 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5122 if (LocaleCompare(keyword,"height") == 0)
5124 height = StringToLong( value );
5127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5133 if (LocaleCompare(keyword,"width") == 0)
5135 width = StringToLong( value );
5138 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5144 if (LocaleCompare(keyword,"x") == 0)
5146 x = StringToLong( value );
5149 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5155 if (LocaleCompare(keyword,"y") == 0)
5157 y = StringToLong( value );
5160 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5165 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5171 msl_info->image[n]->page.width=width;
5172 msl_info->image[n]->page.height=height;
5173 msl_info->image[n]->page.x=x;
5174 msl_info->image[n]->page.y=y;
5177 else if (LocaleCompare((const char *) tag,"resample") == 0)
5183 if (msl_info->image[n] == (Image *) NULL)
5185 ThrowMSLException(OptionError,"NoImagesDefined",
5186 (const char *) tag);
5189 if (attributes == (const xmlChar **) NULL)
5191 x_resolution=DefaultResolution;
5192 y_resolution=DefaultResolution;
5193 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5195 keyword=(const char *) attributes[i++];
5196 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5197 msl_info->attributes[n],(const char *) attributes[i]));
5202 if (LocaleCompare(keyword,"blur") == 0)
5204 msl_info->image[n]->blur=StringToDouble(value);
5207 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5213 if (LocaleCompare(keyword,"geometry") == 0)
5218 flags=ParseGeometry(value,&geometry_info);
5219 if ((flags & SigmaValue) == 0)
5220 geometry_info.sigma*=geometry_info.rho;
5221 x_resolution=geometry_info.rho;
5222 y_resolution=geometry_info.sigma;
5225 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5231 if (LocaleCompare(keyword,"x-resolution") == 0)
5233 x_resolution=StringToDouble(value);
5236 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5242 if (LocaleCompare(keyword,"y-resolution") == 0)
5244 y_resolution=StringToDouble(value);
5247 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5252 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5268 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5270 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5271 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5272 msl_info->image[n]->x_resolution))+0.5);
5273 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5274 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5275 msl_info->image[n]->y_resolution))+0.5);
5276 resample_image=ResizeImage(msl_info->image[n],width,height,
5277 msl_info->image[n]->filter,msl_info->image[n]->blur,
5278 &msl_info->image[n]->exception);
5279 if (resample_image == (Image *) NULL)
5281 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5282 msl_info->image[n]=resample_image;
5286 if (LocaleCompare((const char *) tag,"resize") == 0)
5300 if (msl_info->image[n] == (Image *) NULL)
5302 ThrowMSLException(OptionError,"NoImagesDefined",
5303 (const char *) tag);
5306 filter=UndefinedFilter;
5308 if (attributes != (const xmlChar **) NULL)
5309 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5311 keyword=(const char *) attributes[i++];
5312 attribute=InterpretImageProperties(msl_info->image_info[n],
5313 msl_info->attributes[n],(const char *) attributes[i]);
5314 CloneString(&value,attribute);
5320 if (LocaleCompare(keyword,"filter") == 0)
5322 option=ParseMagickOption(MagickFilterOptions,MagickFalse,
5325 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5327 filter=(FilterTypes) option;
5330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5337 if (LocaleCompare(keyword,"geometry") == 0)
5339 flags=ParseRegionGeometry(msl_info->image[n],value,
5340 &geometry,&exception);
5343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5350 if (LocaleCompare(keyword,"height") == 0)
5352 geometry.height=StringToUnsignedLong(value);
5355 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5362 if (LocaleCompare(keyword,"support") == 0)
5364 blur=StringToDouble(value);
5367 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5374 if (LocaleCompare(keyword,"width") == 0)
5376 geometry.width=StringToLong(value);
5379 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5385 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5391 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5392 geometry.height,filter,blur,&msl_info->image[n]->exception);
5393 if (resize_image == (Image *) NULL)
5395 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5396 msl_info->image[n]=resize_image;
5399 if (LocaleCompare((const char *) tag,"roll") == 0)
5407 if (msl_info->image[n] == (Image *) NULL)
5409 ThrowMSLException(OptionError,"NoImagesDefined",
5410 (const char *) tag);
5413 SetGeometry(msl_info->image[n],&geometry);
5414 if (attributes != (const xmlChar **) NULL)
5415 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5417 keyword=(const char *) attributes[i++];
5418 attribute=InterpretImageProperties(msl_info->image_info[n],
5419 msl_info->attributes[n],(const char *) attributes[i]);
5420 CloneString(&value,attribute);
5426 if (LocaleCompare(keyword,"geometry") == 0)
5428 flags=ParsePageGeometry(msl_info->image[n],value,
5429 &geometry,&exception);
5430 if ((flags & HeightValue) == 0)
5431 geometry.height=geometry.width;
5434 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5441 if (LocaleCompare(keyword,"x") == 0)
5443 geometry.x=StringToLong(value);
5446 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5453 if (LocaleCompare(keyword,"y") == 0)
5455 geometry.y=StringToLong(value);
5458 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5464 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5470 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5471 &msl_info->image[n]->exception);
5472 if (roll_image == (Image *) NULL)
5474 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5475 msl_info->image[n]=roll_image;
5478 else if (LocaleCompare((const char *) tag,"roll") == 0)
5480 /* init the values */
5481 width=msl_info->image[n]->columns;
5482 height=msl_info->image[n]->rows;
5485 if (msl_info->image[n] == (Image *) NULL)
5487 ThrowMSLException(OptionError,"NoImagesDefined",
5488 (const char *) tag);
5491 if (attributes == (const xmlChar **) NULL)
5493 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5495 keyword=(const char *) attributes[i++];
5496 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5497 msl_info->attributes[n],(const char *) attributes[i]));
5503 if (LocaleCompare(keyword,"geometry") == 0)
5505 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5508 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5514 if (LocaleCompare(keyword,"x") == 0)
5516 x = StringToLong( value );
5519 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5525 if (LocaleCompare(keyword,"y") == 0)
5527 y = StringToLong( value );
5530 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5535 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5548 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5549 if (newImage == (Image *) NULL)
5551 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5552 msl_info->image[n]=newImage;
5557 if (LocaleCompare((const char *) tag,"rotate") == 0)
5565 if (msl_info->image[n] == (Image *) NULL)
5567 ThrowMSLException(OptionError,"NoImagesDefined",
5568 (const char *) tag);
5571 if (attributes != (const xmlChar **) NULL)
5572 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5574 keyword=(const char *) attributes[i++];
5575 attribute=InterpretImageProperties(msl_info->image_info[n],
5576 msl_info->attributes[n],(const char *) attributes[i]);
5577 CloneString(&value,attribute);
5583 if (LocaleCompare(keyword,"degrees") == 0)
5585 geometry_info.rho=StringToDouble(value);
5588 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5595 if (LocaleCompare(keyword,"geometry") == 0)
5597 flags=ParseGeometry(value,&geometry_info);
5598 if ((flags & SigmaValue) == 0)
5599 geometry_info.sigma=1.0;
5602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5614 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5615 &msl_info->image[n]->exception);
5616 if (rotate_image == (Image *) NULL)
5618 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5619 msl_info->image[n]=rotate_image;
5622 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5624 /* init the values */
5627 if (msl_info->image[n] == (Image *) NULL)
5629 ThrowMSLException(OptionError,"NoImagesDefined",
5630 (const char *) tag);
5633 if (attributes == (const xmlChar **) NULL)
5635 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5637 keyword=(const char *) attributes[i++];
5638 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5639 msl_info->attributes[n],(const char *) attributes[i]));
5645 if (LocaleCompare(keyword,"degrees") == 0)
5647 degrees = StringToDouble( value );
5650 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5655 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5668 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5669 if (newImage == (Image *) NULL)
5671 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5672 msl_info->image[n]=newImage;
5677 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5682 if (LocaleCompare((const char *) tag,"sample") == 0)
5690 if (msl_info->image[n] == (Image *) NULL)
5692 ThrowMSLException(OptionError,"NoImagesDefined",
5693 (const char *) tag);
5696 if (attributes != (const xmlChar **) NULL)
5697 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5699 keyword=(const char *) attributes[i++];
5700 attribute=InterpretImageProperties(msl_info->image_info[n],
5701 msl_info->attributes[n],(const char *) attributes[i]);
5702 CloneString(&value,attribute);
5708 if (LocaleCompare(keyword,"geometry") == 0)
5710 flags=ParseRegionGeometry(msl_info->image[n],value,
5711 &geometry,&exception);
5714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5721 if (LocaleCompare(keyword,"height") == 0)
5723 geometry.height=StringToUnsignedLong(value);
5726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5733 if (LocaleCompare(keyword,"width") == 0)
5735 geometry.width=StringToLong(value);
5738 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5750 sample_image=SampleImage(msl_info->image[n],geometry.width,
5751 geometry.height,&msl_info->image[n]->exception);
5752 if (sample_image == (Image *) NULL)
5754 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5755 msl_info->image[n]=sample_image;
5758 if (LocaleCompare((const char *) tag,"scale") == 0)
5766 if (msl_info->image[n] == (Image *) NULL)
5768 ThrowMSLException(OptionError,"NoImagesDefined",
5769 (const char *) tag);
5772 if (attributes != (const xmlChar **) NULL)
5773 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5775 keyword=(const char *) attributes[i++];
5776 attribute=InterpretImageProperties(msl_info->image_info[n],
5777 msl_info->attributes[n],(const char *) attributes[i]);
5778 CloneString(&value,attribute);
5784 if (LocaleCompare(keyword,"geometry") == 0)
5786 flags=ParseRegionGeometry(msl_info->image[n],value,
5787 &geometry,&exception);
5790 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5797 if (LocaleCompare(keyword,"height") == 0)
5799 geometry.height=StringToUnsignedLong(value);
5802 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5809 if (LocaleCompare(keyword,"width") == 0)
5811 geometry.width=StringToLong(value);
5814 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5820 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5826 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5827 geometry.height,&msl_info->image[n]->exception);
5828 if (scale_image == (Image *) NULL)
5830 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5831 msl_info->image[n]=scale_image;
5834 if (LocaleCompare((const char *) tag,"segment") == 0)
5845 if (msl_info->image[n] == (Image *) NULL)
5847 ThrowMSLException(OptionError,"NoImagesDefined",
5848 (const char *) tag);
5851 geometry_info.rho=1.0;
5852 geometry_info.sigma=1.5;
5853 colorspace=RGBColorspace;
5854 verbose=MagickFalse;
5855 if (attributes != (const xmlChar **) NULL)
5856 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5858 keyword=(const char *) attributes[i++];
5859 attribute=InterpretImageProperties(msl_info->image_info[n],
5860 msl_info->attributes[n],(const char *) attributes[i]);
5861 CloneString(&value,attribute);
5867 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5869 geometry_info.rho=StringToDouble(value);
5872 if (LocaleCompare(keyword,"colorspace") == 0)
5874 option=ParseMagickOption(MagickColorspaceOptions,
5877 ThrowMSLException(OptionError,
5878 "UnrecognizedColorspaceType",value);
5879 colorspace=(ColorspaceType) option;
5882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5889 if (LocaleCompare(keyword,"geometry") == 0)
5891 flags=ParseGeometry(value,&geometry_info);
5892 if ((flags & SigmaValue) == 0)
5893 geometry_info.sigma=1.5;
5896 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5903 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5905 geometry_info.sigma=StringToDouble(value);
5908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5920 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5921 geometry_info.rho,geometry_info.sigma);
5924 else if (LocaleCompare((const char *) tag, "set") == 0)
5926 if (msl_info->image[n] == (Image *) NULL)
5928 ThrowMSLException(OptionError,"NoImagesDefined",
5929 (const char *) tag);
5933 if (attributes == (const xmlChar **) NULL)
5935 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5937 keyword=(const char *) attributes[i++];
5938 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5939 msl_info->attributes[n],(const char *) attributes[i]));
5945 if (LocaleCompare(keyword,"clip-mask") == 0)
5947 for (j=0; j < msl_info->n; j++)
5952 property=GetImageProperty(msl_info->attributes[j],"id");
5953 if (LocaleCompare(property,value) == 0)
5955 SetImageMask(msl_info->image[n],msl_info->image[j]);
5961 if (LocaleCompare(keyword,"clip-path") == 0)
5963 for (j=0; j < msl_info->n; j++)
5968 property=GetImageProperty(msl_info->attributes[j],"id");
5969 if (LocaleCompare(property,value) == 0)
5971 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5977 if (LocaleCompare(keyword,"colorspace") == 0)
5982 colorspace=(ColorspaceType) ParseMagickOption(
5983 MagickColorspaceOptions,MagickFalse,value);
5985 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5987 (void) TransformImageColorspace(msl_info->image[n],
5988 (ColorspaceType) colorspace);
5991 (void) SetMSLAttributes(msl_info,keyword,value);
5997 if (LocaleCompare(keyword,"density") == 0)
5999 flags=ParseGeometry(value,&geometry_info);
6000 msl_info->image[n]->x_resolution=geometry_info.rho;
6001 msl_info->image[n]->y_resolution=geometry_info.sigma;
6002 if ((flags & SigmaValue) == 0)
6003 msl_info->image[n]->y_resolution=
6004 msl_info->image[n]->x_resolution;
6007 (void) SetMSLAttributes(msl_info,keyword,value);
6013 if (LocaleCompare(keyword, "opacity") == 0)
6015 ssize_t opac = OpaqueOpacity,
6016 len = (ssize_t) strlen( value );
6018 if (value[len-1] == '%') {
6020 (void) CopyMagickString(tmp,value,len);
6021 opac = StringToLong( tmp );
6022 opac = (int)(QuantumRange * ((float)opac/100));
6024 opac = StringToLong( value );
6025 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6028 (void) SetMSLAttributes(msl_info,keyword,value);
6034 if (LocaleCompare(keyword, "page") == 0)
6037 page[MaxTextExtent];
6048 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6049 image_option=GetImageOption(msl_info->image_info[n],"page");
6050 if (image_option != (const char *) NULL)
6051 flags=ParseAbsoluteGeometry(image_option,&geometry);
6052 flags=ParseAbsoluteGeometry(value,&geometry);
6053 (void) FormatMagickString(page,MaxTextExtent,"%.20gx%.20g",
6054 (double) geometry.width,(double) geometry.height);
6055 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6056 (void) FormatMagickString(page,MaxTextExtent,
6057 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6058 (double) geometry.height,(double) geometry.x,(double)
6060 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6061 msl_info->image_info[n]->page=GetPageGeometry(page);
6064 (void) SetMSLAttributes(msl_info,keyword,value);
6069 (void) SetMSLAttributes(msl_info,keyword,value);
6076 if (LocaleCompare((const char *) tag,"shade") == 0)
6087 if (msl_info->image[n] == (Image *) NULL)
6089 ThrowMSLException(OptionError,"NoImagesDefined",
6090 (const char *) tag);
6094 if (attributes != (const xmlChar **) NULL)
6095 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6097 keyword=(const char *) attributes[i++];
6098 attribute=InterpretImageProperties(msl_info->image_info[n],
6099 msl_info->attributes[n],(const char *) attributes[i]);
6100 CloneString(&value,attribute);
6106 if (LocaleCompare(keyword,"azimuth") == 0)
6108 geometry_info.rho=StringToDouble(value);
6111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6118 if (LocaleCompare(keyword,"elevation") == 0)
6120 geometry_info.sigma=StringToDouble(value);
6123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6130 if (LocaleCompare(keyword,"geometry") == 0)
6132 flags=ParseGeometry(value,&geometry_info);
6133 if ((flags & SigmaValue) == 0)
6134 geometry_info.sigma=1.0;
6137 if (LocaleCompare(keyword,"gray") == 0)
6139 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6142 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6144 gray=(MagickBooleanType) option;
6147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6153 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6159 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6160 geometry_info.sigma,&msl_info->image[n]->exception);
6161 if (shade_image == (Image *) NULL)
6163 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6164 msl_info->image[n]=shade_image;
6167 if (LocaleCompare((const char *) tag,"shadow") == 0)
6175 if (msl_info->image[n] == (Image *) NULL)
6177 ThrowMSLException(OptionError,"NoImagesDefined",
6178 (const char *) tag);
6181 if (attributes != (const xmlChar **) NULL)
6182 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6184 keyword=(const char *) attributes[i++];
6185 attribute=InterpretImageProperties(msl_info->image_info[n],
6186 msl_info->attributes[n],(const char *) attributes[i]);
6187 CloneString(&value,attribute);
6193 if (LocaleCompare(keyword,"geometry") == 0)
6195 flags=ParseGeometry(value,&geometry_info);
6196 if ((flags & SigmaValue) == 0)
6197 geometry_info.sigma=1.0;
6200 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6207 if (LocaleCompare(keyword,"opacity") == 0)
6209 geometry_info.rho=StringToLong(value);
6212 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6219 if (LocaleCompare(keyword,"sigma") == 0)
6221 geometry_info.sigma=StringToLong(value);
6229 if (LocaleCompare(keyword,"x") == 0)
6231 geometry_info.xi=StringToDouble(value);
6234 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6241 if (LocaleCompare(keyword,"y") == 0)
6243 geometry_info.psi=StringToLong(value);
6246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6252 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6258 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6259 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6260 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6261 if (shadow_image == (Image *) NULL)
6263 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6264 msl_info->image[n]=shadow_image;
6267 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6269 double radius = 0.0,
6272 if (msl_info->image[n] == (Image *) NULL)
6274 ThrowMSLException(OptionError,"NoImagesDefined",
6275 (const char *) tag);
6279 NOTE: sharpen can have no attributes, since we use all the defaults!
6281 if (attributes != (const xmlChar **) NULL)
6283 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6285 keyword=(const char *) attributes[i++];
6286 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6287 msl_info->attributes[n],(const char *) attributes[i]));
6293 if (LocaleCompare(keyword, "radius") == 0)
6295 radius = StringToDouble( value );
6298 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6304 if (LocaleCompare(keyword,"sigma") == 0)
6306 sigma = StringToLong( value );
6309 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6314 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6328 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6329 if (newImage == (Image *) NULL)
6331 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6332 msl_info->image[n]=newImage;
6336 else if (LocaleCompare((const char *) tag,"shave") == 0)
6338 /* init the values */
6342 if (msl_info->image[n] == (Image *) NULL)
6344 ThrowMSLException(OptionError,"NoImagesDefined",
6345 (const char *) tag);
6348 if (attributes == (const xmlChar **) NULL)
6350 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6352 keyword=(const char *) attributes[i++];
6353 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6354 msl_info->attributes[n],(const char *) attributes[i]));
6360 if (LocaleCompare(keyword,"geometry") == 0)
6362 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6365 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6371 if (LocaleCompare(keyword,"height") == 0)
6373 height = StringToLong( value );
6376 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6382 if (LocaleCompare(keyword,"width") == 0)
6384 width = StringToLong( value );
6387 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6392 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6407 rectInfo.height = height;
6408 rectInfo.width = width;
6413 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6414 &msl_info->image[n]->exception);
6415 if (newImage == (Image *) NULL)
6417 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6418 msl_info->image[n]=newImage;
6423 if (LocaleCompare((const char *) tag,"shear") == 0)
6431 if (msl_info->image[n] == (Image *) NULL)
6433 ThrowMSLException(OptionError,"NoImagesDefined",
6434 (const char *) tag);
6437 if (attributes != (const xmlChar **) NULL)
6438 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6440 keyword=(const char *) attributes[i++];
6441 attribute=InterpretImageProperties(msl_info->image_info[n],
6442 msl_info->attributes[n],(const char *) attributes[i]);
6443 CloneString(&value,attribute);
6449 if (LocaleCompare(keyword, "fill") == 0)
6451 (void) QueryColorDatabase(value,
6452 &msl_info->image[n]->background_color,&exception);
6455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6462 if (LocaleCompare(keyword,"geometry") == 0)
6464 flags=ParseGeometry(value,&geometry_info);
6465 if ((flags & SigmaValue) == 0)
6466 geometry_info.sigma=1.0;
6469 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6476 if (LocaleCompare(keyword,"x") == 0)
6478 geometry_info.rho=StringToDouble(value);
6481 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6488 if (LocaleCompare(keyword,"y") == 0)
6490 geometry_info.sigma=StringToLong(value);
6493 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6505 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6506 geometry_info.sigma,&msl_info->image[n]->exception);
6507 if (shear_image == (Image *) NULL)
6509 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6510 msl_info->image[n]=shear_image;
6513 if (LocaleCompare((const char *) tag,"signature") == 0)
6518 if (msl_info->image[n] == (Image *) NULL)
6520 ThrowMSLException(OptionError,"NoImagesDefined",
6521 (const char *) tag);
6524 if (attributes != (const xmlChar **) NULL)
6525 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6527 keyword=(const char *) attributes[i++];
6528 attribute=InterpretImageProperties(msl_info->image_info[n],
6529 msl_info->attributes[n],(const char *) attributes[i]);
6530 CloneString(&value,attribute);
6535 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6541 (void) SignatureImage(msl_info->image[n]);
6544 if (LocaleCompare((const char *) tag,"solarize") == 0)
6549 if (msl_info->image[n] == (Image *) NULL)
6551 ThrowMSLException(OptionError,"NoImagesDefined",
6552 (const char *) tag);
6555 geometry_info.rho=QuantumRange/2.0;
6556 if (attributes != (const xmlChar **) NULL)
6557 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6559 keyword=(const char *) attributes[i++];
6560 attribute=InterpretImageProperties(msl_info->image_info[n],
6561 msl_info->attributes[n],(const char *) attributes[i]);
6562 CloneString(&value,attribute);
6568 if (LocaleCompare(keyword,"geometry") == 0)
6570 flags=ParseGeometry(value,&geometry_info);
6573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6580 if (LocaleCompare(keyword,"threshold") == 0)
6582 geometry_info.rho=StringToDouble(value);
6585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6591 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6597 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6600 if (LocaleCompare((const char *) tag,"spread") == 0)
6608 if (msl_info->image[n] == (Image *) NULL)
6610 ThrowMSLException(OptionError,"NoImagesDefined",
6611 (const char *) tag);
6614 if (attributes != (const xmlChar **) NULL)
6615 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6617 keyword=(const char *) attributes[i++];
6618 attribute=InterpretImageProperties(msl_info->image_info[n],
6619 msl_info->attributes[n],(const char *) attributes[i]);
6620 CloneString(&value,attribute);
6626 if (LocaleCompare(keyword,"geometry") == 0)
6628 flags=ParseGeometry(value,&geometry_info);
6629 if ((flags & SigmaValue) == 0)
6630 geometry_info.sigma=1.0;
6633 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6640 if (LocaleCompare(keyword,"radius") == 0)
6642 geometry_info.rho=StringToDouble(value);
6645 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6657 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6658 &msl_info->image[n]->exception);
6659 if (spread_image == (Image *) NULL)
6661 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6662 msl_info->image[n]=spread_image;
6665 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6668 watermark = (Image*)NULL;
6670 if (msl_info->image[n] == (Image *) NULL)
6672 ThrowMSLException(OptionError,"NoImagesDefined",
6673 (const char *) tag);
6676 if (attributes == (const xmlChar **) NULL)
6678 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6680 keyword=(const char *) attributes[i++];
6681 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6682 msl_info->attributes[n],(const char *) attributes[i]));
6688 if (LocaleCompare(keyword,"image") == 0)
6690 for (j=0; j<msl_info->n;j++)
6693 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6694 if (theAttr && LocaleCompare(theAttr, value) == 0)
6696 watermark = msl_info->image[j];
6702 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6707 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6716 if ( watermark != (Image*) NULL )
6721 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6722 if (newImage == (Image *) NULL)
6724 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6725 msl_info->image[n]=newImage;
6728 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6730 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6733 stereoImage = (Image*)NULL;
6735 if (msl_info->image[n] == (Image *) NULL)
6737 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6740 if (attributes == (const xmlChar **) NULL)
6742 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6744 keyword=(const char *) attributes[i++];
6745 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6746 msl_info->attributes[n],(const char *) attributes[i]));
6752 if (LocaleCompare(keyword,"image") == 0)
6754 for (j=0; j<msl_info->n;j++)
6757 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6758 if (theAttr && LocaleCompare(theAttr, value) == 0)
6760 stereoImage = msl_info->image[j];
6766 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6771 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6780 if ( stereoImage != (Image*) NULL )
6785 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6786 if (newImage == (Image *) NULL)
6788 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6789 msl_info->image[n]=newImage;
6792 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6794 if (LocaleCompare((const char *) tag,"swap") == 0)
6805 if (msl_info->image[n] == (Image *) NULL)
6807 ThrowMSLException(OptionError,"NoImagesDefined",
6808 (const char *) tag);
6813 if (attributes != (const xmlChar **) NULL)
6814 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6816 keyword=(const char *) attributes[i++];
6817 attribute=InterpretImageProperties(msl_info->image_info[n],
6818 msl_info->attributes[n],(const char *) attributes[i]);
6819 CloneString(&value,attribute);
6825 if (LocaleCompare(keyword,"indexes") == 0)
6827 flags=ParseGeometry(value,&geometry_info);
6828 index=(ssize_t) geometry_info.rho;
6829 if ((flags & SigmaValue) == 0)
6830 swap_index=(ssize_t) geometry_info.sigma;
6833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6848 p=GetImageFromList(msl_info->image[n],index);
6849 q=GetImageFromList(msl_info->image[n],swap_index);
6850 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6852 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6855 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6856 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6857 ReplaceImageInList(&q,swap);
6858 msl_info->image[n]=GetFirstImageInList(q);
6861 if (LocaleCompare((const char *) tag,"swirl") == 0)
6869 if (msl_info->image[n] == (Image *) NULL)
6871 ThrowMSLException(OptionError,"NoImagesDefined",
6872 (const char *) tag);
6875 if (attributes != (const xmlChar **) NULL)
6876 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6878 keyword=(const char *) attributes[i++];
6879 attribute=InterpretImageProperties(msl_info->image_info[n],
6880 msl_info->attributes[n],(const char *) attributes[i]);
6881 CloneString(&value,attribute);
6887 if (LocaleCompare(keyword,"degrees") == 0)
6889 geometry_info.rho=StringToDouble(value);
6892 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6899 if (LocaleCompare(keyword,"geometry") == 0)
6901 flags=ParseGeometry(value,&geometry_info);
6902 if ((flags & SigmaValue) == 0)
6903 geometry_info.sigma=1.0;
6906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6912 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6918 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6919 &msl_info->image[n]->exception);
6920 if (swirl_image == (Image *) NULL)
6922 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6923 msl_info->image[n]=swirl_image;
6926 if (LocaleCompare((const char *) tag,"sync") == 0)
6931 if (msl_info->image[n] == (Image *) NULL)
6933 ThrowMSLException(OptionError,"NoImagesDefined",
6934 (const char *) tag);
6937 if (attributes != (const xmlChar **) NULL)
6938 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6940 keyword=(const char *) attributes[i++];
6941 attribute=InterpretImageProperties(msl_info->image_info[n],
6942 msl_info->attributes[n],(const char *) attributes[i]);
6943 CloneString(&value,attribute);
6948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6954 (void) SyncImage(msl_info->image[n]);
6957 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6962 if (LocaleCompare((const char *) tag,"map") == 0)
6970 if (msl_info->image[n] == (Image *) NULL)
6972 ThrowMSLException(OptionError,"NoImagesDefined",
6973 (const char *) tag);
6976 texture_image=NewImageList();
6977 if (attributes != (const xmlChar **) NULL)
6978 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6980 keyword=(const char *) attributes[i++];
6981 attribute=InterpretImageProperties(msl_info->image_info[n],
6982 msl_info->attributes[n],(const char *) attributes[i]);
6983 CloneString(&value,attribute);
6989 if (LocaleCompare(keyword,"image") == 0)
6990 for (j=0; j < msl_info->n; j++)
6995 attribute=GetImageProperty(msl_info->attributes[j],"id");
6996 if ((attribute != (const char *) NULL) &&
6997 (LocaleCompare(attribute,value) == 0))
6999 texture_image=CloneImage(msl_info->image[j],0,0,
7000 MagickFalse,&exception);
7008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7014 (void) TextureImage(msl_info->image[n],texture_image);
7015 texture_image=DestroyImage(texture_image);
7018 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7020 /* init the values */
7021 double threshold = 0;
7023 if (msl_info->image[n] == (Image *) NULL)
7025 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7028 if (attributes == (const xmlChar **) NULL)
7030 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7032 keyword=(const char *) attributes[i++];
7033 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7034 msl_info->attributes[n],(const char *) attributes[i]));
7040 if (LocaleCompare(keyword,"threshold") == 0)
7042 threshold = StringToDouble( value );
7045 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7050 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7060 BilevelImageChannel(msl_info->image[n],
7061 (ChannelType) ((ssize_t) (AllChannels &~ (ssize_t) OpacityChannel)),
7066 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7068 if (msl_info->image[n] == (Image *) NULL)
7070 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7073 if (attributes == (const xmlChar **) NULL)
7075 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7077 keyword=(const char *) attributes[i++];
7078 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7079 msl_info->attributes[n],(const char *) attributes[i]));
7085 if (LocaleCompare(keyword,"color") == 0)
7090 (void) QueryMagickColor(value,&target,&exception);
7091 (void) TransparentPaintImage(msl_info->image[n],&target,
7092 TransparentOpacity,MagickFalse);
7095 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7100 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7107 else if (LocaleCompare((const char *) tag, "trim") == 0)
7109 if (msl_info->image[n] == (Image *) NULL)
7111 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7115 /* no attributes here */
7117 /* process the image */
7124 /* all zeros on a crop == trim edges! */
7125 rectInfo.height = rectInfo.width = 0;
7126 rectInfo.x = rectInfo.y = 0;
7128 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7129 if (newImage == (Image *) NULL)
7131 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7132 msl_info->image[n]=newImage;
7136 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7141 if (LocaleCompare((const char *) tag,"write") == 0)
7143 if (msl_info->image[n] == (Image *) NULL)
7145 ThrowMSLException(OptionError,"NoImagesDefined",
7146 (const char *) tag);
7149 if (attributes == (const xmlChar **) NULL)
7151 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7153 keyword=(const char *) attributes[i++];
7154 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7155 msl_info->attributes[n],(const char *) attributes[i]));
7161 if (LocaleCompare(keyword,"filename") == 0)
7163 (void) CopyMagickString(msl_info->image[n]->filename,value,
7167 (void) SetMSLAttributes(msl_info,keyword,value);
7171 (void) SetMSLAttributes(msl_info,keyword,value);
7179 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7183 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7187 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7191 if ( value != NULL )
7192 value=DestroyString(value);
7193 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7196 static void MSLEndElement(void *context,const xmlChar *tag)
7205 Called when the end of an element has been detected.
7207 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7209 msl_info=(MSLInfo *) context;
7216 if (LocaleCompare((const char *) tag,"comment") == 0 )
7218 (void) DeleteImageProperty(msl_info->image[n],"comment");
7219 if (msl_info->content == (char *) NULL)
7221 StripString(msl_info->content);
7222 (void) SetImageProperty(msl_info->image[n],"comment",
7231 if (LocaleCompare((const char *) tag, "group") == 0 )
7233 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7235 ssize_t i = (ssize_t)
7236 (msl_info->group_info[msl_info->number_groups-1].numImages);
7239 if (msl_info->image[msl_info->n] != (Image *) NULL)
7240 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7241 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7242 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7246 msl_info->number_groups--;
7253 if (LocaleCompare((const char *) tag, "image") == 0)
7254 MSLPopImage(msl_info);
7260 if (LocaleCompare((const char *) tag,"label") == 0 )
7262 (void) DeleteImageProperty(msl_info->image[n],"label");
7263 if (msl_info->content == (char *) NULL)
7265 StripString(msl_info->content);
7266 (void) SetImageProperty(msl_info->image[n],"label",
7275 if (LocaleCompare((const char *) tag, "msl") == 0 )
7278 This our base element.
7279 at the moment we don't do anything special
7280 but someday we might!
7288 if (msl_info->content != (char *) NULL)
7289 msl_info->content=DestroyString(msl_info->content);
7292 static void MSLCharacters(void *context,const xmlChar *c,int length)
7304 Receiving some characters from the parser.
7306 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7307 " SAX.characters(%s,%d)",c,length);
7308 msl_info=(MSLInfo *) context;
7309 if (msl_info->content != (char *) NULL)
7310 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7311 strlen(msl_info->content)+length+MaxTextExtent,
7312 sizeof(*msl_info->content));
7315 msl_info->content=(char *) NULL;
7316 if (~length >= MaxTextExtent)
7317 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7318 sizeof(*msl_info->content));
7319 if (msl_info->content != (char *) NULL)
7320 *msl_info->content='\0';
7322 if (msl_info->content == (char *) NULL)
7324 p=msl_info->content+strlen(msl_info->content);
7325 for (i=0; i < length; i++)
7330 static void MSLReference(void *context,const xmlChar *name)
7339 Called when an entity reference is detected.
7341 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7342 " SAX.reference(%s)",name);
7343 msl_info=(MSLInfo *) context;
7344 parser=msl_info->parser;
7346 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7348 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7351 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7357 Receiving some ignorable whitespaces from the parser.
7359 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7360 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7361 msl_info=(MSLInfo *) context;
7365 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7366 const xmlChar *data)
7372 A processing instruction has been parsed.
7374 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7375 " SAX.processingInstruction(%s, %s)",
7377 msl_info=(MSLInfo *) context;
7381 static void MSLComment(void *context,const xmlChar *value)
7387 A comment has been parsed.
7389 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7390 " SAX.comment(%s)",value);
7391 msl_info=(MSLInfo *) context;
7395 static void MSLWarning(void *context,const char *format,...)
7399 reason[MaxTextExtent];
7408 Display and format a warning messages, gives file, line, position and
7411 va_start(operands,format);
7412 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7413 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7414 msl_info=(MSLInfo *) context;
7416 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7417 (void) vsprintf(reason,format,operands);
7419 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7421 message=GetExceptionMessage(errno);
7422 ThrowMSLException(CoderError,reason,message);
7423 message=DestroyString(message);
7427 static void MSLError(void *context,const char *format,...)
7430 reason[MaxTextExtent];
7439 Display and format a error formats, gives file, line, position and
7442 va_start(operands,format);
7443 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7444 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7445 msl_info=(MSLInfo *) context;
7447 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7448 (void) vsprintf(reason,format,operands);
7450 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7452 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7456 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7468 Called when a pcdata block has been parsed.
7470 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7471 " SAX.pcdata(%s, %d)",value,length);
7472 msl_info=(MSLInfo *) context;
7474 parser=msl_info->parser;
7475 child=xmlGetLastChild(parser->node);
7476 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7478 xmlTextConcat(child,value,length);
7481 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7484 static void MSLExternalSubset(void *context,const xmlChar *name,
7485 const xmlChar *external_id,const xmlChar *system_id)
7500 Does this document has an external subset?
7502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7503 " SAX.externalSubset(%s %s %s)",name,
7504 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7505 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7506 msl_info=(MSLInfo *) context;
7508 parser=msl_info->parser;
7509 if (((external_id == NULL) && (system_id == NULL)) ||
7510 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7511 (msl_info->document == 0)))
7513 input=MSLResolveEntity(context,external_id,system_id);
7516 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7517 parser_context=(*parser);
7518 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7519 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7521 parser->errNo=XML_ERR_NO_MEMORY;
7522 parser->input=parser_context.input;
7523 parser->inputNr=parser_context.inputNr;
7524 parser->inputMax=parser_context.inputMax;
7525 parser->inputTab=parser_context.inputTab;
7531 xmlPushInput(parser,input);
7532 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7533 if (input->filename == (char *) NULL)
7534 input->filename=(char *) xmlStrdup(system_id);
7537 input->base=parser->input->cur;
7538 input->cur=parser->input->cur;
7540 xmlParseExternalSubset(parser,external_id,system_id);
7541 while (parser->inputNr > 1)
7542 (void) xmlPopInput(parser);
7543 xmlFreeInputStream(parser->input);
7544 xmlFree(parser->inputTab);
7545 parser->input=parser_context.input;
7546 parser->inputNr=parser_context.inputNr;
7547 parser->inputMax=parser_context.inputMax;
7548 parser->inputTab=parser_context.inputTab;
7551 #if defined(__cplusplus) || defined(c_plusplus)
7555 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7556 ExceptionInfo *exception)
7559 message[MaxTextExtent];
7582 assert(image_info != (const ImageInfo *) NULL);
7583 assert(image_info->signature == MagickSignature);
7584 if (image_info->debug != MagickFalse)
7585 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7586 image_info->filename);
7587 assert(image != (Image **) NULL);
7588 msl_image=AcquireImage(image_info);
7589 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7590 if (status == MagickFalse)
7592 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7593 msl_image->filename);
7594 msl_image=DestroyImageList(msl_image);
7595 return(MagickFalse);
7597 msl_image->columns=1;
7602 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7603 msl_info.exception=exception;
7604 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7605 sizeof(*msl_info.image_info));
7606 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7607 sizeof(*msl_info.draw_info));
7608 /* top of the stack is the MSL file itself */
7609 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7610 msl_info.attributes=(Image **) AcquireMagickMemory(
7611 sizeof(*msl_info.attributes));
7612 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7613 sizeof(*msl_info.group_info));
7614 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7615 (msl_info.image == (Image **) NULL) ||
7616 (msl_info.attributes == (Image **) NULL) ||
7617 (msl_info.group_info == (MSLGroupInfo *) NULL))
7618 ThrowFatalException(ResourceLimitFatalError,
7619 "UnableToInterpretMSLImage");
7620 *msl_info.image_info=CloneImageInfo(image_info);
7621 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7622 *msl_info.attributes=AcquireImage(image_info);
7623 msl_info.group_info[0].numImages=0;
7624 /* the first slot is used to point to the MSL file image */
7625 *msl_info.image=msl_image;
7626 if (*image != (Image *) NULL)
7627 MSLPushImage(&msl_info,*image);
7628 (void) xmlSubstituteEntitiesDefault(1);
7629 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7630 sax_modules.internalSubset=MSLInternalSubset;
7631 sax_modules.isStandalone=MSLIsStandalone;
7632 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7633 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7634 sax_modules.resolveEntity=MSLResolveEntity;
7635 sax_modules.getEntity=MSLGetEntity;
7636 sax_modules.entityDecl=MSLEntityDeclaration;
7637 sax_modules.notationDecl=MSLNotationDeclaration;
7638 sax_modules.attributeDecl=MSLAttributeDeclaration;
7639 sax_modules.elementDecl=MSLElementDeclaration;
7640 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7641 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7642 sax_modules.startDocument=MSLStartDocument;
7643 sax_modules.endDocument=MSLEndDocument;
7644 sax_modules.startElement=MSLStartElement;
7645 sax_modules.endElement=MSLEndElement;
7646 sax_modules.reference=MSLReference;
7647 sax_modules.characters=MSLCharacters;
7648 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7649 sax_modules.processingInstruction=MSLProcessingInstructions;
7650 sax_modules.comment=MSLComment;
7651 sax_modules.warning=MSLWarning;
7652 sax_modules.error=MSLError;
7653 sax_modules.fatalError=MSLError;
7654 sax_modules.getParameterEntity=MSLGetParameterEntity;
7655 sax_modules.cdataBlock=MSLCDataBlock;
7656 sax_modules.externalSubset=MSLExternalSubset;
7657 sax_handler=(&sax_modules);
7658 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7659 msl_image->filename);
7660 while (ReadBlobString(msl_image,message) != (char *) NULL)
7662 n=(ssize_t) strlen(message);
7665 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7668 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7669 if (msl_info.exception->severity >= ErrorException)
7672 if (msl_info.exception->severity == UndefinedException)
7673 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7674 xmlFreeParserCtxt(msl_info.parser);
7675 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7677 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7678 msl_info.group_info);
7679 if (*image == (Image *) NULL)
7680 *image=(*msl_info.image);
7681 if ((*msl_info.image)->exception.severity != UndefinedException)
7682 return(MagickFalse);
7686 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7694 assert(image_info != (const ImageInfo *) NULL);
7695 assert(image_info->signature == MagickSignature);
7696 if (image_info->debug != MagickFalse)
7697 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7698 image_info->filename);
7699 assert(exception != (ExceptionInfo *) NULL);
7700 assert(exception->signature == MagickSignature);
7701 image=(Image *) NULL;
7702 (void) ProcessMSLScript(image_info,&image,exception);
7703 return(GetFirstImageInList(image));
7708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7712 % R e g i s t e r M S L I m a g e %
7716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7718 % RegisterMSLImage() adds attributes for the MSL image format to
7719 % the list of supported formats. The attributes include the image format
7720 % tag, a method to read and/or write the format, whether the format
7721 % supports the saving of more than one frame to the same file or blob,
7722 % whether the format supports native in-memory I/O, and a brief
7723 % description of the format.
7725 % The format of the RegisterMSLImage method is:
7727 % size_t RegisterMSLImage(void)
7730 ModuleExport size_t RegisterMSLImage(void)
7735 entry=SetMagickInfo("MSL");
7736 #if defined(MAGICKCORE_XML_DELEGATE)
7737 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7738 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7740 entry->description=ConstantString("Magick Scripting Language");
7741 entry->module=ConstantString("MSL");
7742 (void) RegisterMagickInfo(entry);
7743 return(MagickImageCoderSignature);
7746 #if defined(MAGICKCORE_XML_DELEGATE)
7748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7752 % S e t M S L A t t r i b u t e s %
7756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7758 % SetMSLAttributes() ...
7760 % The format of the SetMSLAttributes method is:
7762 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7763 % const char *keyword,const char *value)
7765 % A description of each parameter follows:
7767 % o msl_info: the MSL info.
7769 % o keyword: the keyword.
7771 % o value: the value.
7774 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7801 assert(msl_info != (MSLInfo *) NULL);
7802 if (keyword == (const char *) NULL)
7804 if (value == (const char *) NULL)
7806 exception=msl_info->exception;
7808 attributes=msl_info->attributes[n];
7809 image_info=msl_info->image_info[n];
7810 draw_info=msl_info->draw_info[n];
7811 image=msl_info->image[n];
7817 if (LocaleCompare(keyword,"adjoin") == 0)
7822 adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7824 ThrowMSLException(OptionError,"UnrecognizedType",value);
7825 image_info->adjoin=(MagickBooleanType) adjoin;
7828 if (LocaleCompare(keyword,"alpha") == 0)
7833 alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
7835 ThrowMSLException(OptionError,"UnrecognizedType",value);
7836 if (image != (Image *) NULL)
7837 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7840 if (LocaleCompare(keyword,"antialias") == 0)
7845 antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
7847 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7848 image_info->antialias=(MagickBooleanType) antialias;
7851 if (LocaleCompare(keyword,"area-limit") == 0)
7856 limit=MagickResourceInfinity;
7857 if (LocaleCompare(value,"unlimited") != 0)
7858 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7859 (void) SetMagickResourceLimit(AreaResource,limit);
7862 if (LocaleCompare(keyword,"attenuate") == 0)
7864 (void) SetImageOption(image_info,keyword,value);
7867 if (LocaleCompare(keyword,"authenticate") == 0)
7869 (void) CloneString(&image_info->density,value);
7872 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7878 if (LocaleCompare(keyword,"background") == 0)
7880 (void) QueryColorDatabase(value,&image_info->background_color,
7884 if (LocaleCompare(keyword,"bias") == 0)
7886 if (image == (Image *) NULL)
7888 image->bias=SiPrefixToDouble(value,QuantumRange);
7891 if (LocaleCompare(keyword,"blue-primary") == 0)
7893 if (image == (Image *) NULL)
7895 flags=ParseGeometry(value,&geometry_info);
7896 image->chromaticity.blue_primary.x=geometry_info.rho;
7897 image->chromaticity.blue_primary.y=geometry_info.sigma;
7898 if ((flags & SigmaValue) == 0)
7899 image->chromaticity.blue_primary.y=
7900 image->chromaticity.blue_primary.x;
7903 if (LocaleCompare(keyword,"bordercolor") == 0)
7905 (void) QueryColorDatabase(value,&image_info->border_color,
7909 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7915 if (LocaleCompare(keyword,"density") == 0)
7917 (void) CloneString(&image_info->density,value);
7918 (void) CloneString(&draw_info->density,value);
7921 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7927 if (LocaleCompare(keyword,"fill") == 0)
7929 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7930 (void) SetImageOption(image_info,keyword,value);
7933 if (LocaleCompare(keyword,"filename") == 0)
7935 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7938 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7944 if (LocaleCompare(keyword,"gravity") == 0)
7949 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
7951 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7952 (void) SetImageOption(image_info,keyword,value);
7955 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7961 if (LocaleCompare(keyword,"id") == 0)
7963 (void) SetImageProperty(attributes,keyword,value);
7966 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7972 if (LocaleCompare(keyword,"magick") == 0)
7974 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7977 if (LocaleCompare(keyword,"mattecolor") == 0)
7979 (void) QueryColorDatabase(value,&image_info->matte_color,
7983 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7989 if (LocaleCompare(keyword,"pointsize") == 0)
7991 image_info->pointsize=StringToDouble(value);
7992 draw_info->pointsize=StringToDouble(value);
7995 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8001 if (LocaleCompare(keyword,"quality") == 0)
8003 image_info->quality=StringToLong(value);
8004 if (image == (Image *) NULL)
8006 image->quality=StringToLong(value);
8014 if (LocaleCompare(keyword,"size") == 0)
8016 (void) CloneString(&image_info->size,value);
8019 if (LocaleCompare(keyword,"stroke") == 0)
8021 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8022 (void) SetImageOption(image_info,keyword,value);
8025 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8030 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8043 % U n r e g i s t e r M S L I m a g e %
8047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8049 % UnregisterMSLImage() removes format registrations made by the
8050 % MSL module from the list of supported formats.
8052 % The format of the UnregisterMSLImage method is:
8054 % UnregisterMSLImage(void)
8057 ModuleExport void UnregisterMSLImage(void)
8059 (void) UnregisterMagickInfo("MSL");
8062 #if defined(MAGICKCORE_XML_DELEGATE)
8064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8068 % W r i t e M S L I m a g e %
8072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8074 % WriteMSLImage() writes an image to a file in MVG image format.
8076 % The format of the WriteMSLImage method is:
8078 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8080 % A description of each parameter follows.
8082 % o image_info: the image info.
8084 % o image: The image.
8087 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8089 assert(image_info != (const ImageInfo *) NULL);
8090 assert(image_info->signature == MagickSignature);
8091 assert(image != (Image *) NULL);
8092 assert(image->signature == MagickSignature);
8093 if (image->debug != MagickFalse)
8094 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8095 (void) ReferenceImage(image);
8096 (void) ProcessMSLScript(image_info,&image,&image->exception);