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 "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/colormap.h"
53 #include "MagickCore/color-private.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/enhance.h"
61 #include "MagickCore/exception.h"
62 #include "MagickCore/exception-private.h"
63 #include "MagickCore/fx.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/image.h"
66 #include "MagickCore/image-private.h"
67 #include "MagickCore/list.h"
68 #include "MagickCore/log.h"
69 #include "MagickCore/magick.h"
70 #include "MagickCore/memory_.h"
71 #include "MagickCore/module.h"
72 #include "MagickCore/option.h"
73 #include "MagickCore/paint.h"
74 #include "MagickCore/pixel-accessor.h"
75 #include "MagickCore/profile.h"
76 #include "MagickCore/property.h"
77 #include "MagickCore/quantize.h"
78 #include "MagickCore/quantum-private.h"
79 #include "MagickCore/registry.h"
80 #include "MagickCore/resize.h"
81 #include "MagickCore/resource_.h"
82 #include "MagickCore/segment.h"
83 #include "MagickCore/shear.h"
84 #include "MagickCore/signature.h"
85 #include "MagickCore/static.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/string-private.h"
88 #include "MagickCore/transform.h"
89 #include "MagickCore/threshold.h"
90 #include "MagickCore/utility.h"
91 #if defined(MAGICKCORE_XML_DELEGATE)
92 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
93 # if defined(__MINGW32__)
96 # include <win32config.h>
99 # include <libxml/parser.h>
100 # include <libxml/xmlmemory.h>
101 # include <libxml/parserInternals.h>
102 # include <libxml/xmlerror.h>
108 #define ThrowMSLException(severity,tag,reason) \
109 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
113 Typedef declaractions.
115 typedef struct _MSLGroupInfo
118 numImages; /* how many images are in this group */
121 typedef struct _MSLInfo
146 #if defined(MAGICKCORE_XML_DELEGATE)
156 Forward declarations.
158 #if defined(MAGICKCORE_XML_DELEGATE)
159 static MagickBooleanType
160 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
162 static MagickBooleanType
163 SetMSLAttributes(MSLInfo *,const char *,const char *);
166 #if defined(MAGICKCORE_XML_DELEGATE)
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % R e a d M S L I m a g e %
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
180 % It allocates the memory necessary for the new Image structure and returns a
181 % pointer to the new image.
183 % The format of the ReadMSLImage method is:
185 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
187 % A description of each parameter follows:
189 % o image_info: the image info.
191 % o exception: return any errors or warnings in this structure.
195 #if defined(__cplusplus) || defined(c_plusplus)
199 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
200 ExceptionInfo *exception)
214 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
215 sans_exception=AcquireExceptionInfo();
216 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
217 sans_exception=DestroyExceptionInfo(sans_exception);
218 if (image != (Image *) NULL)
220 read_info=CloneImageInfo(image_info);
221 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
222 image=ReadImage(read_info,exception);
223 read_info=DestroyImageInfo(read_info);
224 if (image != (Image *) NULL)
225 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
229 static int IsPathDirectory(const char *path)
237 if ((path == (const char *) NULL) || (*path == '\0'))
239 status=GetPathAttributes(path,&attributes);
240 if (status == MagickFalse)
242 if (S_ISDIR(attributes.st_mode) == 0)
247 static int MSLIsStandalone(void *context)
253 Is this document tagged standalone?
255 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
256 msl_info=(MSLInfo *) context;
257 return(msl_info->document->standalone == 1);
260 static int MSLHasInternalSubset(void *context)
266 Does this document has an internal subset?
268 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
269 " SAX.MSLHasInternalSubset()");
270 msl_info=(MSLInfo *) context;
271 return(msl_info->document->intSubset != NULL);
274 static int MSLHasExternalSubset(void *context)
280 Does this document has an external subset?
282 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
283 " SAX.MSLHasExternalSubset()");
284 msl_info=(MSLInfo *) context;
285 return(msl_info->document->extSubset != NULL);
288 static void MSLInternalSubset(void *context,const xmlChar *name,
289 const xmlChar *external_id,const xmlChar *system_id)
295 Does this document has an internal subset?
297 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
298 " SAX.internalSubset(%s %s %s)",name,
299 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
300 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
301 msl_info=(MSLInfo *) context;
302 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
305 static xmlParserInputPtr MSLResolveEntity(void *context,
306 const xmlChar *public_id,const xmlChar *system_id)
315 Special entity resolver, better left to the parser, it has more
316 context than the application layer. The default behaviour is to
317 not resolve the entities, in that case the ENTITY_REF nodes are
318 built in the structure (and the parameter values).
320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
321 " SAX.resolveEntity(%s, %s)",
322 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
323 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
324 msl_info=(MSLInfo *) context;
325 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
326 public_id,msl_info->parser);
330 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
336 Get an entity by name.
338 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
339 " SAX.MSLGetEntity(%s)",(const char *) name);
340 msl_info=(MSLInfo *) context;
341 return(xmlGetDocEntity(msl_info->document,name));
344 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
350 Get a parameter entity by name.
352 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
353 " SAX.getParameterEntity(%s)",(const char *) name);
354 msl_info=(MSLInfo *) context;
355 return(xmlGetParameterEntity(msl_info->document,name));
358 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
359 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
365 An entity definition has been parsed.
367 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
368 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
369 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
370 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
372 msl_info=(MSLInfo *) context;
373 if (msl_info->parser->inSubset == 1)
374 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
377 if (msl_info->parser->inSubset == 2)
378 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
382 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
383 const xmlChar *name,int type,int value,const xmlChar *default_value,
384 xmlEnumerationPtr tree)
397 An attribute definition has been parsed.
399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
400 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
402 msl_info=(MSLInfo *) context;
403 fullname=(xmlChar *) NULL;
404 prefix=(xmlChar *) NULL;
405 parser=msl_info->parser;
406 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
407 if (parser->inSubset == 1)
408 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
409 element,fullname,prefix,(xmlAttributeType) type,
410 (xmlAttributeDefault) value,default_value,tree);
412 if (parser->inSubset == 2)
413 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
414 element,fullname,prefix,(xmlAttributeType) type,
415 (xmlAttributeDefault) value,default_value,tree);
416 if (prefix != (xmlChar *) NULL)
418 if (fullname != (xmlChar *) NULL)
422 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
423 xmlElementContentPtr content)
432 An element definition has been parsed.
434 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
435 " SAX.elementDecl(%s, %d, ...)",name,type);
436 msl_info=(MSLInfo *) context;
437 parser=msl_info->parser;
438 if (parser->inSubset == 1)
439 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
440 name,(xmlElementTypeVal) type,content);
442 if (parser->inSubset == 2)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
444 name,(xmlElementTypeVal) type,content);
447 static void MSLNotationDeclaration(void *context,const xmlChar *name,
448 const xmlChar *public_id,const xmlChar *system_id)
457 What to do when a notation declaration has been parsed.
459 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
460 " SAX.notationDecl(%s, %s, %s)",name,
461 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
462 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
463 msl_info=(MSLInfo *) context;
464 parser=msl_info->parser;
465 if (parser->inSubset == 1)
466 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
467 name,public_id,system_id);
469 if (parser->inSubset == 2)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
474 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
475 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
481 What to do when an unparsed entity declaration is parsed.
483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
484 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
485 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
486 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
488 msl_info=(MSLInfo *) context;
489 (void) xmlAddDocEntity(msl_info->document,name,
490 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
494 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
500 Receive the document locator at startup, actually xmlDefaultSAXLocator.
502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
503 " SAX.setDocumentLocator()\n");
505 msl_info=(MSLInfo *) context;
509 static void MSLStartDocument(void *context)
518 Called when the document start being processed.
520 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521 " SAX.startDocument()");
522 msl_info=(MSLInfo *) context;
523 parser=msl_info->parser;
524 msl_info->document=xmlNewDoc(parser->version);
525 if (msl_info->document == (xmlDocPtr) NULL)
527 if (parser->encoding == NULL)
528 msl_info->document->encoding=NULL;
530 msl_info->document->encoding=xmlStrdup(parser->encoding);
531 msl_info->document->standalone=parser->standalone;
534 static void MSLEndDocument(void *context)
540 Called when the document end has been detected.
542 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
543 msl_info=(MSLInfo *) context;
544 if (msl_info->content != (char *) NULL)
545 msl_info->content=DestroyString(msl_info->content);
548 static void MSLPushImage(MSLInfo *msl_info,Image *image)
553 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
554 assert(msl_info != (MSLInfo *) NULL);
557 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
558 (n+1),sizeof(*msl_info->image_info));
559 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
560 (n+1),sizeof(*msl_info->draw_info));
561 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
562 (n+1),sizeof(*msl_info->attributes));
563 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
564 sizeof(*msl_info->image));
565 if ((msl_info->image_info == (ImageInfo **) NULL) ||
566 (msl_info->draw_info == (DrawInfo **) NULL) ||
567 (msl_info->attributes == (Image **) NULL) ||
568 (msl_info->image == (Image **) NULL))
569 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
570 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
571 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
572 msl_info->draw_info[n-1]);
573 if (image == (Image *) NULL)
574 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
576 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
577 msl_info->image[n]=(Image *) image;
578 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
579 (msl_info->attributes[n] == (Image *) NULL))
580 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
581 if (msl_info->number_groups != 0)
582 msl_info->group_info[msl_info->number_groups-1].numImages++;
585 static void MSLPopImage(MSLInfo *msl_info)
587 if (msl_info->number_groups != 0)
589 if (msl_info->image[msl_info->n] != (Image *) NULL)
590 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
591 msl_info->attributes[msl_info->n]=DestroyImage(
592 msl_info->attributes[msl_info->n]);
593 msl_info->image_info[msl_info->n]=DestroyImageInfo(
594 msl_info->image_info[msl_info->n]);
598 static void MSLStartElement(void *context,const xmlChar *tag,
599 const xmlChar **attributes)
658 Called when an opening tag has been processed.
660 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
661 " SAX.startElement(%s",tag);
662 GetExceptionInfo(&exception);
663 msl_info=(MSLInfo *) context;
665 keyword=(const char *) NULL;
667 SetGeometryInfo(&geometry_info);
668 channel=DefaultChannels;
674 if (LocaleCompare((const char *) tag,"add-noise") == 0)
685 if (msl_info->image[n] == (Image *) NULL)
687 ThrowMSLException(OptionError,"NoImagesDefined",
692 if (attributes != (const xmlChar **) NULL)
693 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
695 keyword=(const char *) attributes[i++];
696 attribute=InterpretImageProperties(msl_info->image_info[n],
697 msl_info->attributes[n],(const char *) attributes[i]);
698 CloneString(&value,attribute);
704 if (LocaleCompare(keyword,"channel") == 0)
706 option=ParseChannelOption(value);
708 ThrowMSLException(OptionError,"UnrecognizedChannelType",
710 channel=(ChannelType) option;
713 ThrowMSLException(OptionError,"UnrecognizedAttribute",
720 if (LocaleCompare(keyword,"noise") == 0)
722 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
725 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
727 noise=(NoiseType) option;
730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
742 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
743 noise_image=AddNoiseImage(msl_info->image[n],noise,
744 &msl_info->image[n]->exception);
745 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
746 if (noise_image == (Image *) NULL)
748 msl_info->image[n]=DestroyImage(msl_info->image[n]);
749 msl_info->image[n]=noise_image;
752 if (LocaleCompare((const char *) tag,"annotate") == 0)
760 if (msl_info->image[n] == (Image *) NULL)
762 ThrowMSLException(OptionError,"NoImagesDefined",
766 draw_info=CloneDrawInfo(msl_info->image_info[n],
767 msl_info->draw_info[n]);
769 current=draw_info->affine;
770 GetAffineMatrix(&affine);
771 if (attributes != (const xmlChar **) NULL)
772 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
774 keyword=(const char *) attributes[i++];
775 attribute=InterpretImageProperties(msl_info->image_info[n],
776 msl_info->attributes[n],(const char *) attributes[i]);
777 CloneString(&value,attribute);
783 if (LocaleCompare(keyword,"affine") == 0)
789 draw_info->affine.sx=InterpretLocaleValue(p,&p);
792 draw_info->affine.rx=InterpretLocaleValue(p,&p);
795 draw_info->affine.ry=InterpretLocaleValue(p,&p);
798 draw_info->affine.sy=InterpretLocaleValue(p,&p);
801 draw_info->affine.tx=InterpretLocaleValue(p,&p);
804 draw_info->affine.ty=InterpretLocaleValue(p,&p);
807 if (LocaleCompare(keyword,"align") == 0)
809 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
812 ThrowMSLException(OptionError,"UnrecognizedAlignType",
814 draw_info->align=(AlignType) option;
817 if (LocaleCompare(keyword,"antialias") == 0)
819 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
822 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
824 draw_info->stroke_antialias=(MagickBooleanType) option;
825 draw_info->text_antialias=(MagickBooleanType) option;
828 ThrowMSLException(OptionError,"UnrecognizedAttribute",
835 if (LocaleCompare(keyword,"density") == 0)
837 CloneString(&draw_info->density,value);
840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
847 if (LocaleCompare(keyword,"encoding") == 0)
849 CloneString(&draw_info->encoding,value);
852 ThrowMSLException(OptionError,"UnrecognizedAttribute",
859 if (LocaleCompare(keyword, "fill") == 0)
861 (void) QueryColorDatabase(value,&draw_info->fill,
865 if (LocaleCompare(keyword,"family") == 0)
867 CloneString(&draw_info->family,value);
870 if (LocaleCompare(keyword,"font") == 0)
872 CloneString(&draw_info->font,value);
875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
882 if (LocaleCompare(keyword,"geometry") == 0)
884 flags=ParseGravityGeometry(msl_info->image[n],value,
885 &geometry,&exception);
888 if (LocaleCompare(keyword,"gravity") == 0)
890 option=ParseCommandOption(MagickGravityOptions,
893 ThrowMSLException(OptionError,"UnrecognizedGravityType",
895 draw_info->gravity=(GravityType) option;
898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
905 if (LocaleCompare(keyword,"pointsize") == 0)
907 draw_info->pointsize=InterpretLocaleValue(value,
911 ThrowMSLException(OptionError,"UnrecognizedAttribute",
918 if (LocaleCompare(keyword,"rotate") == 0)
920 angle=InterpretLocaleValue(value,(char **) NULL);
921 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
922 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
923 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
924 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
927 ThrowMSLException(OptionError,"UnrecognizedAttribute",
934 if (LocaleCompare(keyword,"scale") == 0)
936 flags=ParseGeometry(value,&geometry_info);
937 if ((flags & SigmaValue) == 0)
938 geometry_info.sigma=1.0;
939 affine.sx=geometry_info.rho;
940 affine.sy=geometry_info.sigma;
943 if (LocaleCompare(keyword,"skewX") == 0)
945 angle=InterpretLocaleValue(value,(char **) NULL);
946 affine.ry=tan(DegreesToRadians(fmod((double) angle,
950 if (LocaleCompare(keyword,"skewY") == 0)
952 angle=InterpretLocaleValue(value,(char **) NULL);
953 affine.rx=tan(DegreesToRadians(fmod((double) angle,
957 if (LocaleCompare(keyword,"stretch") == 0)
959 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
962 ThrowMSLException(OptionError,"UnrecognizedStretchType",
964 draw_info->stretch=(StretchType) option;
967 if (LocaleCompare(keyword, "stroke") == 0)
969 (void) QueryColorDatabase(value,&draw_info->stroke,
973 if (LocaleCompare(keyword,"strokewidth") == 0)
975 draw_info->stroke_width=StringToLong(value);
978 if (LocaleCompare(keyword,"style") == 0)
980 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
983 ThrowMSLException(OptionError,"UnrecognizedStyleType",
985 draw_info->style=(StyleType) option;
988 ThrowMSLException(OptionError,"UnrecognizedAttribute",
995 if (LocaleCompare(keyword,"text") == 0)
997 CloneString(&draw_info->text,value);
1000 if (LocaleCompare(keyword,"translate") == 0)
1002 flags=ParseGeometry(value,&geometry_info);
1003 if ((flags & SigmaValue) == 0)
1004 geometry_info.sigma=1.0;
1005 affine.tx=geometry_info.rho;
1006 affine.ty=geometry_info.sigma;
1009 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1016 if (LocaleCompare(keyword, "undercolor") == 0)
1018 (void) QueryColorDatabase(value,&draw_info->undercolor,
1022 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1029 if (LocaleCompare(keyword,"weight") == 0)
1031 draw_info->weight=StringToLong(value);
1034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1041 if (LocaleCompare(keyword,"x") == 0)
1043 geometry.x=StringToLong(value);
1046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1053 if (LocaleCompare(keyword,"y") == 0)
1055 geometry.y=StringToLong(value);
1058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1070 (void) FormatLocaleString(text,MaxTextExtent,
1071 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1072 geometry.height,(double) geometry.x,(double) geometry.y);
1073 CloneString(&draw_info->geometry,text);
1074 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1075 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1076 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1077 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1078 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1080 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1082 (void) AnnotateImage(msl_info->image[n],draw_info);
1083 draw_info=DestroyDrawInfo(draw_info);
1086 if (LocaleCompare((const char *) tag,"append") == 0)
1094 if (msl_info->image[n] == (Image *) NULL)
1096 ThrowMSLException(OptionError,"NoImagesDefined",
1097 (const char *) tag);
1101 if (attributes != (const xmlChar **) NULL)
1102 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1104 keyword=(const char *) attributes[i++];
1105 attribute=InterpretImageProperties(msl_info->image_info[n],
1106 msl_info->attributes[n],(const char *) attributes[i]);
1107 CloneString(&value,attribute);
1113 if (LocaleCompare(keyword,"stack") == 0)
1115 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1118 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1120 stack=(MagickBooleanType) option;
1123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1129 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1135 append_image=AppendImages(msl_info->image[n],stack,
1136 &msl_info->image[n]->exception);
1137 if (append_image == (Image *) NULL)
1139 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1140 msl_info->image[n]=append_image;
1143 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1149 if (LocaleCompare((const char *) tag,"blur") == 0)
1157 if (msl_info->image[n] == (Image *) NULL)
1159 ThrowMSLException(OptionError,"NoImagesDefined",
1160 (const char *) tag);
1163 if (attributes != (const xmlChar **) NULL)
1164 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1166 keyword=(const char *) attributes[i++];
1167 attribute=InterpretImageProperties(msl_info->image_info[n],
1168 msl_info->attributes[n],(const char *) attributes[i]);
1169 CloneString(&value,attribute);
1175 if (LocaleCompare(keyword,"channel") == 0)
1177 option=ParseChannelOption(value);
1179 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1181 channel=(ChannelType) option;
1184 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1191 if (LocaleCompare(keyword,"geometry") == 0)
1193 flags=ParseGeometry(value,&geometry_info);
1194 if ((flags & SigmaValue) == 0)
1195 geometry_info.sigma=1.0;
1198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1205 if (LocaleCompare(keyword,"radius") == 0)
1207 geometry_info.rho=InterpretLocaleValue(value,
1211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1218 if (LocaleCompare(keyword,"sigma") == 0)
1220 geometry_info.sigma=StringToLong(value);
1223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1235 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1236 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1237 geometry_info.sigma,&msl_info->image[n]->exception);
1238 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
1239 if (blur_image == (Image *) NULL)
1241 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1242 msl_info->image[n]=blur_image;
1245 if (LocaleCompare((const char *) tag,"border") == 0)
1253 if (msl_info->image[n] == (Image *) NULL)
1255 ThrowMSLException(OptionError,"NoImagesDefined",
1256 (const char *) tag);
1259 SetGeometry(msl_info->image[n],&geometry);
1260 if (attributes != (const xmlChar **) NULL)
1261 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1263 keyword=(const char *) attributes[i++];
1264 attribute=InterpretImageProperties(msl_info->image_info[n],
1265 msl_info->attributes[n],(const char *) attributes[i]);
1266 CloneString(&value,attribute);
1272 if (LocaleCompare(keyword,"compose") == 0)
1274 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1277 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1279 msl_info->image[n]->compose=(CompositeOperator) option;
1282 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1289 if (LocaleCompare(keyword, "fill") == 0)
1291 (void) QueryColorDatabase(value,
1292 &msl_info->image[n]->border_color,&exception);
1295 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1302 if (LocaleCompare(keyword,"geometry") == 0)
1304 flags=ParsePageGeometry(msl_info->image[n],value,
1305 &geometry,&exception);
1306 if ((flags & HeightValue) == 0)
1307 geometry.height=geometry.width;
1310 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1317 if (LocaleCompare(keyword,"height") == 0)
1319 geometry.height=StringToLong(value);
1322 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1329 if (LocaleCompare(keyword,"width") == 0)
1331 geometry.width=StringToLong(value);
1334 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1340 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1346 border_image=BorderImage(msl_info->image[n],&geometry,
1347 &msl_info->image[n]->exception);
1348 if (border_image == (Image *) NULL)
1350 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1351 msl_info->image[n]=border_image;
1354 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1359 if (LocaleCompare((const char *) tag,"colorize") == 0)
1362 opacity[MaxTextExtent];
1373 if (msl_info->image[n] == (Image *) NULL)
1375 ThrowMSLException(OptionError,"NoImagesDefined",
1376 (const char *) tag);
1379 target=msl_info->image[n]->background_color;
1380 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1381 if (attributes != (const xmlChar **) NULL)
1382 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1384 keyword=(const char *) attributes[i++];
1385 attribute=InterpretImageProperties(msl_info->image_info[n],
1386 msl_info->attributes[n],(const char *) attributes[i]);
1387 CloneString(&value,attribute);
1393 if (LocaleCompare(keyword,"fill") == 0)
1395 (void) QueryColorDatabase(value,&target,
1396 &msl_info->image[n]->exception);
1399 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1406 if (LocaleCompare(keyword,"opacity") == 0)
1408 (void) CopyMagickString(opacity,value,MaxTextExtent);
1411 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1417 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1423 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1424 &msl_info->image[n]->exception);
1425 if (colorize_image == (Image *) NULL)
1427 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1428 msl_info->image[n]=colorize_image;
1431 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1433 double radius = 0.0,
1436 if (msl_info->image[n] == (Image *) NULL)
1438 ThrowMSLException(OptionError,"NoImagesDefined",
1439 (const char *) tag);
1443 NOTE: charcoal can have no attributes, since we use all the defaults!
1445 if (attributes != (const xmlChar **) NULL)
1447 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1449 keyword=(const char *) attributes[i++];
1450 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1451 msl_info->attributes[n],(const char *) attributes[i]));
1457 if (LocaleCompare(keyword, "radius") == 0)
1459 radius = InterpretLocaleValue(value,(char **) NULL);
1462 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1468 if (LocaleCompare(keyword,"sigma") == 0)
1470 sigma = StringToLong( value );
1473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1492 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1493 &msl_info->image[n]->exception);
1494 if (newImage == (Image *) NULL)
1496 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1497 msl_info->image[n]=newImage;
1501 if (LocaleCompare((const char *) tag,"chop") == 0)
1509 if (msl_info->image[n] == (Image *) NULL)
1511 ThrowMSLException(OptionError,"NoImagesDefined",
1512 (const char *) tag);
1515 SetGeometry(msl_info->image[n],&geometry);
1516 if (attributes != (const xmlChar **) NULL)
1517 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1519 keyword=(const char *) attributes[i++];
1520 attribute=InterpretImageProperties(msl_info->image_info[n],
1521 msl_info->attributes[n],(const char *) attributes[i]);
1522 CloneString(&value,attribute);
1528 if (LocaleCompare(keyword,"geometry") == 0)
1530 flags=ParsePageGeometry(msl_info->image[n],value,
1531 &geometry,&exception);
1532 if ((flags & HeightValue) == 0)
1533 geometry.height=geometry.width;
1536 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1543 if (LocaleCompare(keyword,"height") == 0)
1545 geometry.height=StringToLong(value);
1548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1555 if (LocaleCompare(keyword,"width") == 0)
1557 geometry.width=StringToLong(value);
1560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1567 if (LocaleCompare(keyword,"x") == 0)
1569 geometry.x=StringToLong(value);
1572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 if (LocaleCompare(keyword,"y") == 0)
1581 geometry.y=StringToLong(value);
1584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1596 chop_image=ChopImage(msl_info->image[n],&geometry,
1597 &msl_info->image[n]->exception);
1598 if (chop_image == (Image *) NULL)
1600 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1601 msl_info->image[n]=chop_image;
1604 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1613 Color floodfill image.
1615 if (msl_info->image[n] == (Image *) NULL)
1617 ThrowMSLException(OptionError,"NoImagesDefined",
1618 (const char *) tag);
1621 draw_info=CloneDrawInfo(msl_info->image_info[n],
1622 msl_info->draw_info[n]);
1623 SetGeometry(msl_info->image[n],&geometry);
1624 paint_method=FloodfillMethod;
1625 if (attributes != (const xmlChar **) NULL)
1626 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1628 keyword=(const char *) attributes[i++];
1629 attribute=InterpretImageProperties(msl_info->image_info[n],
1630 msl_info->attributes[n],(const char *) attributes[i]);
1631 CloneString(&value,attribute);
1637 if (LocaleCompare(keyword,"bordercolor") == 0)
1639 (void) QueryMagickColor(value,&target,&exception);
1640 paint_method=FillToBorderMethod;
1643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1650 if (LocaleCompare(keyword,"fill") == 0)
1652 (void) QueryColorDatabase(value,&draw_info->fill,
1656 if (LocaleCompare(keyword,"fuzz") == 0)
1658 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1662 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1669 if (LocaleCompare(keyword,"geometry") == 0)
1671 flags=ParsePageGeometry(msl_info->image[n],value,
1672 &geometry,&exception);
1673 if ((flags & HeightValue) == 0)
1674 geometry.height=geometry.width;
1675 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1676 geometry.x,geometry.y,&target,&exception);
1679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1686 if (LocaleCompare(keyword,"x") == 0)
1688 geometry.x=StringToLong(value);
1689 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1690 geometry.x,geometry.y,&target,&exception);
1693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1700 if (LocaleCompare(keyword,"y") == 0)
1702 geometry.y=StringToLong(value);
1703 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1704 geometry.x,geometry.y,&target,&exception);
1707 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1713 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1719 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1720 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1721 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
1722 draw_info=DestroyDrawInfo(draw_info);
1725 if (LocaleCompare((const char *) tag,"comment") == 0)
1727 if (LocaleCompare((const char *) tag,"composite") == 0)
1730 composite_geometry[MaxTextExtent];
1745 if (msl_info->image[n] == (Image *) NULL)
1747 ThrowMSLException(OptionError,"NoImagesDefined",
1748 (const char *) tag);
1751 composite_image=NewImageList();
1752 compose=OverCompositeOp;
1753 if (attributes != (const xmlChar **) NULL)
1754 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1756 keyword=(const char *) attributes[i++];
1757 attribute=InterpretImageProperties(msl_info->image_info[n],
1758 msl_info->attributes[n],(const char *) attributes[i]);
1759 CloneString(&value,attribute);
1765 if (LocaleCompare(keyword,"compose") == 0)
1767 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1770 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1772 compose=(CompositeOperator) option;
1780 if (LocaleCompare(keyword,"image") == 0)
1781 for (j=0; j < msl_info->n; j++)
1786 attribute=GetImageProperty(msl_info->attributes[j],"id");
1787 if ((attribute != (const char *) NULL) &&
1788 (LocaleCompare(attribute,value) == 0))
1790 composite_image=CloneImage(msl_info->image[j],0,0,
1791 MagickFalse,&exception);
1801 if (composite_image == (Image *) NULL)
1803 rotate_image=NewImageList();
1804 SetGeometry(msl_info->image[n],&geometry);
1805 if (attributes != (const xmlChar **) NULL)
1806 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1808 keyword=(const char *) attributes[i++];
1809 attribute=InterpretImageProperties(msl_info->image_info[n],
1810 msl_info->attributes[n],(const char *) attributes[i]);
1811 CloneString(&value,attribute);
1817 if (LocaleCompare(keyword,"blend") == 0)
1819 (void) SetImageArtifact(composite_image,
1820 "compose:args",value);
1823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1830 if (LocaleCompare(keyword,"channel") == 0)
1832 option=ParseChannelOption(value);
1834 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1836 channel=(ChannelType) option;
1839 if (LocaleCompare(keyword, "color") == 0)
1841 (void) QueryColorDatabase(value,
1842 &composite_image->background_color,&exception);
1845 if (LocaleCompare(keyword,"compose") == 0)
1847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1854 if (LocaleCompare(keyword,"geometry") == 0)
1856 flags=ParsePageGeometry(msl_info->image[n],value,
1857 &geometry,&exception);
1858 if ((flags & HeightValue) == 0)
1859 geometry.height=geometry.width;
1860 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1861 geometry.y,&target,&exception);
1864 if (LocaleCompare(keyword,"gravity") == 0)
1866 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1869 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1871 msl_info->image[n]->gravity=(GravityType) option;
1874 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1881 if (LocaleCompare(keyword,"image") == 0)
1883 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1890 if (LocaleCompare(keyword,"mask") == 0)
1891 for (j=0; j < msl_info->n; j++)
1896 attribute=GetImageProperty(msl_info->attributes[j],"id");
1897 if ((attribute != (const char *) NULL) &&
1898 (LocaleCompare(value,value) == 0))
1900 SetImageType(composite_image,TrueColorMatteType);
1901 (void) CompositeImage(composite_image,
1902 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1913 if (LocaleCompare(keyword,"opacity") == 0)
1928 opacity=StringToLong(value);
1929 if (compose != DissolveCompositeOp)
1931 (void) SetImageOpacity(composite_image,(Quantum)
1935 (void) SetImageArtifact(msl_info->image[n],
1936 "compose:args",value);
1937 if (composite_image->matte != MagickTrue)
1938 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1939 composite_view=AcquireCacheView(composite_image);
1940 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1942 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1943 (ssize_t) composite_image->columns,1,&exception);
1944 for (x=0; x < (ssize_t) composite_image->columns; x++)
1946 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1947 SetPixelAlpha(composite_image,
1948 ClampToQuantum(opacity),q);
1949 q+=GetPixelChannels(composite_image);
1951 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1954 composite_view=DestroyCacheView(composite_view);
1957 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1964 if (LocaleCompare(keyword,"rotate") == 0)
1966 rotate_image=RotateImage(composite_image,
1967 InterpretLocaleValue(value,(char **) NULL),&exception);
1970 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1977 if (LocaleCompare(keyword,"tile") == 0)
1982 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1985 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1987 tile=(MagickBooleanType) option;
1989 if (rotate_image != (Image *) NULL)
1990 (void) SetImageArtifact(rotate_image,
1991 "compose:outside-overlay","false");
1993 (void) SetImageArtifact(composite_image,
1994 "compose:outside-overlay","false");
1995 image=msl_info->image[n];
1996 height=composite_image->rows;
1997 width=composite_image->columns;
1998 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1999 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2001 if (rotate_image != (Image *) NULL)
2002 (void) CompositeImage(image,compose,rotate_image,
2005 (void) CompositeImage(image,compose,
2006 composite_image,x,y);
2008 if (rotate_image != (Image *) NULL)
2009 rotate_image=DestroyImage(rotate_image);
2012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2019 if (LocaleCompare(keyword,"x") == 0)
2021 geometry.x=StringToLong(value);
2022 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2023 geometry.y,&target,&exception);
2026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2033 if (LocaleCompare(keyword,"y") == 0)
2035 geometry.y=StringToLong(value);
2036 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2037 geometry.y,&target,&exception);
2040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2052 image=msl_info->image[n];
2053 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2054 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2055 (double) composite_image->rows,(double) geometry.x,(double)
2057 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2059 channel_mask=SetPixelChannelMask(image,channel);
2060 if (rotate_image == (Image *) NULL)
2061 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
2067 geometry.x-=(ssize_t) (rotate_image->columns-
2068 composite_image->columns)/2;
2069 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2070 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
2071 rotate_image=DestroyImage(rotate_image);
2073 (void) SetPixelChannelMask(image,channel_mask);
2074 composite_image=DestroyImage(composite_image);
2077 if (LocaleCompare((const char *) tag,"contrast") == 0)
2085 if (msl_info->image[n] == (Image *) NULL)
2087 ThrowMSLException(OptionError,"NoImagesDefined",
2088 (const char *) tag);
2091 sharpen=MagickFalse;
2092 if (attributes != (const xmlChar **) NULL)
2093 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2095 keyword=(const char *) attributes[i++];
2096 attribute=InterpretImageProperties(msl_info->image_info[n],
2097 msl_info->attributes[n],(const char *) attributes[i]);
2098 CloneString(&value,attribute);
2104 if (LocaleCompare(keyword,"sharpen") == 0)
2106 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2109 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2111 sharpen=(MagickBooleanType) option;
2114 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2126 (void) ContrastImage(msl_info->image[n],sharpen,
2127 &msl_info->image[n]->exception);
2130 if (LocaleCompare((const char *) tag,"crop") == 0)
2138 if (msl_info->image[n] == (Image *) NULL)
2140 ThrowMSLException(OptionError,"NoImagesDefined",
2141 (const char *) tag);
2144 SetGeometry(msl_info->image[n],&geometry);
2145 if (attributes != (const xmlChar **) NULL)
2146 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2148 keyword=(const char *) attributes[i++];
2149 attribute=InterpretImageProperties(msl_info->image_info[n],
2150 msl_info->attributes[n],(const char *) attributes[i]);
2151 CloneString(&value,attribute);
2157 if (LocaleCompare(keyword,"geometry") == 0)
2159 flags=ParseGravityGeometry(msl_info->image[n],value,
2160 &geometry,&exception);
2163 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2170 if (LocaleCompare(keyword,"height") == 0)
2172 geometry.height=StringToLong(value);
2175 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2182 if (LocaleCompare(keyword,"width") == 0)
2184 geometry.width=StringToLong(value);
2187 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2194 if (LocaleCompare(keyword,"x") == 0)
2196 geometry.x=StringToLong(value);
2199 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2206 if (LocaleCompare(keyword,"y") == 0)
2208 geometry.y=StringToLong(value);
2211 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2223 crop_image=CropImage(msl_info->image[n],&geometry,
2224 &msl_info->image[n]->exception);
2225 if (crop_image == (Image *) NULL)
2227 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2228 msl_info->image[n]=crop_image;
2231 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2237 Cycle-colormap image.
2239 if (msl_info->image[n] == (Image *) NULL)
2241 ThrowMSLException(OptionError,"NoImagesDefined",
2242 (const char *) tag);
2246 if (attributes != (const xmlChar **) NULL)
2247 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2249 keyword=(const char *) attributes[i++];
2250 attribute=InterpretImageProperties(msl_info->image_info[n],
2251 msl_info->attributes[n],(const char *) attributes[i]);
2252 CloneString(&value,attribute);
2258 if (LocaleCompare(keyword,"display") == 0)
2260 display=StringToLong(value);
2263 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2269 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2275 (void) CycleColormapImage(msl_info->image[n],display);
2278 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2283 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2291 if (msl_info->image[n] == (Image *) NULL)
2293 ThrowMSLException(OptionError,"NoImagesDefined",
2294 (const char *) tag);
2297 if (attributes != (const xmlChar **) NULL)
2298 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2300 keyword=(const char *) attributes[i++];
2301 attribute=InterpretImageProperties(msl_info->image_info[n],
2302 msl_info->attributes[n],(const char *) attributes[i]);
2303 CloneString(&value,attribute);
2304 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2306 despeckle_image=DespeckleImage(msl_info->image[n],
2307 &msl_info->image[n]->exception);
2308 if (despeckle_image == (Image *) NULL)
2310 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2311 msl_info->image[n]=despeckle_image;
2314 if (LocaleCompare((const char *) tag,"display") == 0)
2316 if (msl_info->image[n] == (Image *) NULL)
2318 ThrowMSLException(OptionError,"NoImagesDefined",
2319 (const char *) tag);
2322 if (attributes != (const xmlChar **) NULL)
2323 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2325 keyword=(const char *) attributes[i++];
2326 attribute=InterpretImageProperties(msl_info->image_info[n],
2327 msl_info->attributes[n],(const char *) attributes[i]);
2328 CloneString(&value,attribute);
2333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2339 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2340 &msl_info->image[n]->exception);
2343 if (LocaleCompare((const char *) tag,"draw") == 0)
2346 text[MaxTextExtent];
2351 if (msl_info->image[n] == (Image *) NULL)
2353 ThrowMSLException(OptionError,"NoImagesDefined",
2354 (const char *) tag);
2357 draw_info=CloneDrawInfo(msl_info->image_info[n],
2358 msl_info->draw_info[n]);
2360 current=draw_info->affine;
2361 GetAffineMatrix(&affine);
2362 if (attributes != (const xmlChar **) NULL)
2363 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2365 keyword=(const char *) attributes[i++];
2366 attribute=InterpretImageProperties(msl_info->image_info[n],
2367 msl_info->attributes[n],(const char *) attributes[i]);
2368 CloneString(&value,attribute);
2374 if (LocaleCompare(keyword,"affine") == 0)
2380 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2383 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2386 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2389 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2392 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2395 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2398 if (LocaleCompare(keyword,"align") == 0)
2400 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2403 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2405 draw_info->align=(AlignType) option;
2408 if (LocaleCompare(keyword,"antialias") == 0)
2410 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2413 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2415 draw_info->stroke_antialias=(MagickBooleanType) option;
2416 draw_info->text_antialias=(MagickBooleanType) option;
2419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2426 if (LocaleCompare(keyword,"density") == 0)
2428 CloneString(&draw_info->density,value);
2431 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2438 if (LocaleCompare(keyword,"encoding") == 0)
2440 CloneString(&draw_info->encoding,value);
2443 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2450 if (LocaleCompare(keyword, "fill") == 0)
2452 (void) QueryColorDatabase(value,&draw_info->fill,
2456 if (LocaleCompare(keyword,"family") == 0)
2458 CloneString(&draw_info->family,value);
2461 if (LocaleCompare(keyword,"font") == 0)
2463 CloneString(&draw_info->font,value);
2466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2473 if (LocaleCompare(keyword,"geometry") == 0)
2475 flags=ParsePageGeometry(msl_info->image[n],value,
2476 &geometry,&exception);
2477 if ((flags & HeightValue) == 0)
2478 geometry.height=geometry.width;
2481 if (LocaleCompare(keyword,"gravity") == 0)
2483 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2486 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2488 draw_info->gravity=(GravityType) option;
2491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2498 if (LocaleCompare(keyword,"primitive") == 0)
2500 CloneString(&draw_info->primitive,value);
2503 if (LocaleCompare(keyword,"pointsize") == 0)
2505 draw_info->pointsize=InterpretLocaleValue(value,
2509 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2516 if (LocaleCompare(keyword,"rotate") == 0)
2518 angle=InterpretLocaleValue(value,(char **) NULL);
2519 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2520 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2521 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2522 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2525 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2532 if (LocaleCompare(keyword,"scale") == 0)
2534 flags=ParseGeometry(value,&geometry_info);
2535 if ((flags & SigmaValue) == 0)
2536 geometry_info.sigma=1.0;
2537 affine.sx=geometry_info.rho;
2538 affine.sy=geometry_info.sigma;
2541 if (LocaleCompare(keyword,"skewX") == 0)
2543 angle=InterpretLocaleValue(value,(char **) NULL);
2544 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2547 if (LocaleCompare(keyword,"skewY") == 0)
2549 angle=InterpretLocaleValue(value,(char **) NULL);
2550 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2553 if (LocaleCompare(keyword,"stretch") == 0)
2555 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2558 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2560 draw_info->stretch=(StretchType) option;
2563 if (LocaleCompare(keyword, "stroke") == 0)
2565 (void) QueryColorDatabase(value,&draw_info->stroke,
2569 if (LocaleCompare(keyword,"strokewidth") == 0)
2571 draw_info->stroke_width=StringToLong(value);
2574 if (LocaleCompare(keyword,"style") == 0)
2576 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2579 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2581 draw_info->style=(StyleType) option;
2584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2591 if (LocaleCompare(keyword,"text") == 0)
2593 CloneString(&draw_info->text,value);
2596 if (LocaleCompare(keyword,"translate") == 0)
2598 flags=ParseGeometry(value,&geometry_info);
2599 if ((flags & SigmaValue) == 0)
2600 geometry_info.sigma=1.0;
2601 affine.tx=geometry_info.rho;
2602 affine.ty=geometry_info.sigma;
2605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2612 if (LocaleCompare(keyword, "undercolor") == 0)
2614 (void) QueryColorDatabase(value,&draw_info->undercolor,
2618 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2625 if (LocaleCompare(keyword,"weight") == 0)
2627 draw_info->weight=StringToLong(value);
2630 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2637 if (LocaleCompare(keyword,"x") == 0)
2639 geometry.x=StringToLong(value);
2642 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2649 if (LocaleCompare(keyword,"y") == 0)
2651 geometry.y=StringToLong(value);
2654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2660 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2666 (void) FormatLocaleString(text,MaxTextExtent,
2667 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2668 geometry.height,(double) geometry.x,(double) geometry.y);
2669 CloneString(&draw_info->geometry,text);
2670 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2671 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2672 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2673 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2674 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2676 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2678 (void) DrawImage(msl_info->image[n],draw_info);
2679 draw_info=DestroyDrawInfo(draw_info);
2682 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2687 if (LocaleCompare((const char *) tag,"edge") == 0)
2695 if (msl_info->image[n] == (Image *) NULL)
2697 ThrowMSLException(OptionError,"NoImagesDefined",
2698 (const char *) tag);
2701 if (attributes != (const xmlChar **) NULL)
2702 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2704 keyword=(const char *) attributes[i++];
2705 attribute=InterpretImageProperties(msl_info->image_info[n],
2706 msl_info->attributes[n],(const char *) attributes[i]);
2707 CloneString(&value,attribute);
2713 if (LocaleCompare(keyword,"geometry") == 0)
2715 flags=ParseGeometry(value,&geometry_info);
2716 if ((flags & SigmaValue) == 0)
2717 geometry_info.sigma=1.0;
2720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2727 if (LocaleCompare(keyword,"radius") == 0)
2729 geometry_info.rho=InterpretLocaleValue(value,
2733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2745 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2746 &msl_info->image[n]->exception);
2747 if (edge_image == (Image *) NULL)
2749 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2750 msl_info->image[n]=edge_image;
2753 if (LocaleCompare((const char *) tag,"emboss") == 0)
2761 if (msl_info->image[n] == (Image *) NULL)
2763 ThrowMSLException(OptionError,"NoImagesDefined",
2764 (const char *) tag);
2767 if (attributes != (const xmlChar **) NULL)
2768 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2770 keyword=(const char *) attributes[i++];
2771 attribute=InterpretImageProperties(msl_info->image_info[n],
2772 msl_info->attributes[n],(const char *) attributes[i]);
2773 CloneString(&value,attribute);
2779 if (LocaleCompare(keyword,"geometry") == 0)
2781 flags=ParseGeometry(value,&geometry_info);
2782 if ((flags & SigmaValue) == 0)
2783 geometry_info.sigma=1.0;
2786 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2793 if (LocaleCompare(keyword,"radius") == 0)
2795 geometry_info.rho=InterpretLocaleValue(value,
2799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2806 if (LocaleCompare(keyword,"sigma") == 0)
2808 geometry_info.sigma=StringToLong(value);
2811 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2817 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2823 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2824 geometry_info.sigma,&msl_info->image[n]->exception);
2825 if (emboss_image == (Image *) NULL)
2827 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2828 msl_info->image[n]=emboss_image;
2831 if (LocaleCompare((const char *) tag,"enhance") == 0)
2839 if (msl_info->image[n] == (Image *) NULL)
2841 ThrowMSLException(OptionError,"NoImagesDefined",
2842 (const char *) tag);
2845 if (attributes != (const xmlChar **) NULL)
2846 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2848 keyword=(const char *) attributes[i++];
2849 attribute=InterpretImageProperties(msl_info->image_info[n],
2850 msl_info->attributes[n],(const char *) attributes[i]);
2851 CloneString(&value,attribute);
2852 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2854 enhance_image=EnhanceImage(msl_info->image[n],
2855 &msl_info->image[n]->exception);
2856 if (enhance_image == (Image *) NULL)
2858 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2859 msl_info->image[n]=enhance_image;
2862 if (LocaleCompare((const char *) tag,"equalize") == 0)
2867 if (msl_info->image[n] == (Image *) NULL)
2869 ThrowMSLException(OptionError,"NoImagesDefined",
2870 (const char *) tag);
2873 if (attributes != (const xmlChar **) NULL)
2874 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2876 keyword=(const char *) attributes[i++];
2877 attribute=InterpretImageProperties(msl_info->image_info[n],
2878 msl_info->attributes[n],(const char *) attributes[i]);
2879 CloneString(&value,attribute);
2884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2890 (void) EqualizeImage(msl_info->image[n],
2891 &msl_info->image[n]->exception);
2894 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2899 if (LocaleCompare((const char *) tag, "flatten") == 0)
2901 if (msl_info->image[n] == (Image *) NULL)
2903 ThrowMSLException(OptionError,"NoImagesDefined",
2904 (const char *) tag);
2908 /* no attributes here */
2910 /* process the image */
2915 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2916 &msl_info->image[n]->exception);
2917 if (newImage == (Image *) NULL)
2919 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2920 msl_info->image[n]=newImage;
2924 if (LocaleCompare((const char *) tag,"flip") == 0)
2932 if (msl_info->image[n] == (Image *) NULL)
2934 ThrowMSLException(OptionError,"NoImagesDefined",
2935 (const char *) tag);
2938 if (attributes != (const xmlChar **) NULL)
2939 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2941 keyword=(const char *) attributes[i++];
2942 attribute=InterpretImageProperties(msl_info->image_info[n],
2943 msl_info->attributes[n],(const char *) attributes[i]);
2944 CloneString(&value,attribute);
2945 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2947 flip_image=FlipImage(msl_info->image[n],
2948 &msl_info->image[n]->exception);
2949 if (flip_image == (Image *) NULL)
2951 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2952 msl_info->image[n]=flip_image;
2955 if (LocaleCompare((const char *) tag,"flop") == 0)
2963 if (msl_info->image[n] == (Image *) NULL)
2965 ThrowMSLException(OptionError,"NoImagesDefined",
2966 (const char *) tag);
2969 if (attributes != (const xmlChar **) NULL)
2970 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2972 keyword=(const char *) attributes[i++];
2973 attribute=InterpretImageProperties(msl_info->image_info[n],
2974 msl_info->attributes[n],(const char *) attributes[i]);
2975 CloneString(&value,attribute);
2976 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2978 flop_image=FlopImage(msl_info->image[n],
2979 &msl_info->image[n]->exception);
2980 if (flop_image == (Image *) NULL)
2982 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2983 msl_info->image[n]=flop_image;
2986 if (LocaleCompare((const char *) tag,"frame") == 0)
2997 if (msl_info->image[n] == (Image *) NULL)
2999 ThrowMSLException(OptionError,"NoImagesDefined",
3000 (const char *) tag);
3003 SetGeometry(msl_info->image[n],&geometry);
3004 if (attributes != (const xmlChar **) NULL)
3005 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3007 keyword=(const char *) attributes[i++];
3008 attribute=InterpretImageProperties(msl_info->image_info[n],
3009 msl_info->attributes[n],(const char *) attributes[i]);
3010 CloneString(&value,attribute);
3016 if (LocaleCompare(keyword,"compose") == 0)
3018 option=ParseCommandOption(MagickComposeOptions,
3021 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3023 msl_info->image[n]->compose=(CompositeOperator) option;
3026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3033 if (LocaleCompare(keyword, "fill") == 0)
3035 (void) QueryColorDatabase(value,
3036 &msl_info->image[n]->matte_color,&exception);
3039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3046 if (LocaleCompare(keyword,"geometry") == 0)
3048 flags=ParsePageGeometry(msl_info->image[n],value,
3049 &geometry,&exception);
3050 if ((flags & HeightValue) == 0)
3051 geometry.height=geometry.width;
3052 frame_info.width=geometry.width;
3053 frame_info.height=geometry.height;
3054 frame_info.outer_bevel=geometry.x;
3055 frame_info.inner_bevel=geometry.y;
3058 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3065 if (LocaleCompare(keyword,"height") == 0)
3067 frame_info.height=StringToLong(value);
3070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3077 if (LocaleCompare(keyword,"inner") == 0)
3079 frame_info.inner_bevel=StringToLong(value);
3082 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3089 if (LocaleCompare(keyword,"outer") == 0)
3091 frame_info.outer_bevel=StringToLong(value);
3094 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3101 if (LocaleCompare(keyword,"width") == 0)
3103 frame_info.width=StringToLong(value);
3106 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3112 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3118 frame_info.x=(ssize_t) frame_info.width;
3119 frame_info.y=(ssize_t) frame_info.height;
3120 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3121 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3122 frame_image=FrameImage(msl_info->image[n],&frame_info,
3123 &msl_info->image[n]->exception);
3124 if (frame_image == (Image *) NULL)
3126 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3127 msl_info->image[n]=frame_image;
3130 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3135 if (LocaleCompare((const char *) tag,"gamma") == 0)
3138 gamma[MaxTextExtent];
3146 if (msl_info->image[n] == (Image *) NULL)
3148 ThrowMSLException(OptionError,"NoImagesDefined",
3149 (const char *) tag);
3152 channel=UndefinedChannel;
3157 if (attributes != (const xmlChar **) NULL)
3158 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3160 keyword=(const char *) attributes[i++];
3161 attribute=InterpretImageProperties(msl_info->image_info[n],
3162 msl_info->attributes[n],(const char *) attributes[i]);
3163 CloneString(&value,attribute);
3169 if (LocaleCompare(keyword,"blue") == 0)
3171 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3174 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3181 if (LocaleCompare(keyword,"channel") == 0)
3183 option=ParseChannelOption(value);
3185 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3187 channel=(ChannelType) option;
3190 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3197 if (LocaleCompare(keyword,"gamma") == 0)
3199 (void) CopyMagickString(gamma,value,MaxTextExtent);
3202 if (LocaleCompare(keyword,"green") == 0)
3204 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3214 if (LocaleCompare(keyword,"red") == 0)
3216 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3225 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3232 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3233 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3234 (void) GammaImage(msl_info->image[n],atof(gamma),
3235 &msl_info->image[n]->exception);
3238 else if (LocaleCompare((const char *) tag,"get") == 0)
3240 if (msl_info->image[n] == (Image *) NULL)
3242 ThrowMSLException(OptionError,"NoImagesDefined",
3243 (const char *) tag);
3246 if (attributes == (const xmlChar **) NULL)
3248 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3250 keyword=(const char *) attributes[i++];
3251 CloneString(&value,(const char *) attributes[i]);
3252 (void) CopyMagickString(key,value,MaxTextExtent);
3258 if (LocaleCompare(keyword,"height") == 0)
3260 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3261 (double) msl_info->image[n]->rows);
3262 (void) SetImageProperty(msl_info->attributes[n],key,value);
3265 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3270 if (LocaleCompare(keyword,"width") == 0)
3272 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3273 (double) msl_info->image[n]->columns);
3274 (void) SetImageProperty(msl_info->attributes[n],key,value);
3277 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3281 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3288 else if (LocaleCompare((const char *) tag, "group") == 0)
3290 msl_info->number_groups++;
3291 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3292 msl_info->group_info,msl_info->number_groups+1UL,
3293 sizeof(*msl_info->group_info));
3296 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3301 if (LocaleCompare((const char *) tag,"image") == 0)
3303 MSLPushImage(msl_info,(Image *) NULL);
3304 if (attributes == (const xmlChar **) NULL)
3306 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3308 keyword=(const char *) attributes[i++];
3309 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3310 msl_info->attributes[n],(const char *) attributes[i]));
3316 if (LocaleCompare(keyword,"color") == 0)
3321 (void) CopyMagickString(msl_info->image_info[n]->filename,
3322 "xc:",MaxTextExtent);
3323 (void) ConcatenateMagickString(msl_info->image_info[n]->
3324 filename,value,MaxTextExtent);
3325 next_image=ReadImage(msl_info->image_info[n],&exception);
3326 CatchException(&exception);
3327 if (next_image == (Image *) NULL)
3329 if (msl_info->image[n] == (Image *) NULL)
3330 msl_info->image[n]=next_image;
3337 Link image into image list.
3339 p=msl_info->image[n];
3340 while (p->next != (Image *) NULL)
3341 p=GetNextImageInList(p);
3342 next_image->previous=p;
3347 (void) SetMSLAttributes(msl_info,keyword,value);
3352 (void) SetMSLAttributes(msl_info,keyword,value);
3359 if (LocaleCompare((const char *) tag,"implode") == 0)
3367 if (msl_info->image[n] == (Image *) NULL)
3369 ThrowMSLException(OptionError,"NoImagesDefined",
3370 (const char *) tag);
3373 if (attributes != (const xmlChar **) NULL)
3374 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3376 keyword=(const char *) attributes[i++];
3377 attribute=InterpretImageProperties(msl_info->image_info[n],
3378 msl_info->attributes[n],(const char *) attributes[i]);
3379 CloneString(&value,attribute);
3385 if (LocaleCompare(keyword,"amount") == 0)
3387 geometry_info.rho=InterpretLocaleValue(value,
3391 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3398 if (LocaleCompare(keyword,"geometry") == 0)
3400 flags=ParseGeometry(value,&geometry_info);
3401 if ((flags & SigmaValue) == 0)
3402 geometry_info.sigma=1.0;
3405 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3411 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3417 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3418 &msl_info->image[n]->exception);
3419 if (implode_image == (Image *) NULL)
3421 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3422 msl_info->image[n]=implode_image;
3425 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3430 if (LocaleCompare((const char *) tag,"label") == 0)
3432 if (LocaleCompare((const char *) tag, "level") == 0)
3435 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3437 if (msl_info->image[n] == (Image *) NULL)
3439 ThrowMSLException(OptionError,"NoImagesDefined",
3440 (const char *) tag);
3443 if (attributes == (const xmlChar **) NULL)
3445 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3447 keyword=(const char *) attributes[i++];
3448 CloneString(&value,(const char *) attributes[i]);
3449 (void) CopyMagickString(key,value,MaxTextExtent);
3455 if (LocaleCompare(keyword,"black") == 0)
3457 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3460 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3466 if (LocaleCompare(keyword,"gamma") == 0)
3468 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3477 if (LocaleCompare(keyword,"white") == 0)
3479 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3487 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3494 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3495 &msl_info->image[n]->exception);
3502 if (LocaleCompare((const char *) tag,"magnify") == 0)
3510 if (msl_info->image[n] == (Image *) NULL)
3512 ThrowMSLException(OptionError,"NoImagesDefined",
3513 (const char *) tag);
3516 if (attributes != (const xmlChar **) NULL)
3517 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3519 keyword=(const char *) attributes[i++];
3520 attribute=InterpretImageProperties(msl_info->image_info[n],
3521 msl_info->attributes[n],(const char *) attributes[i]);
3522 CloneString(&value,attribute);
3523 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3525 magnify_image=MagnifyImage(msl_info->image[n],
3526 &msl_info->image[n]->exception);
3527 if (magnify_image == (Image *) NULL)
3529 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3530 msl_info->image[n]=magnify_image;
3533 if (LocaleCompare((const char *) tag,"map") == 0)
3547 if (msl_info->image[n] == (Image *) NULL)
3549 ThrowMSLException(OptionError,"NoImagesDefined",
3550 (const char *) tag);
3553 affinity_image=NewImageList();
3555 if (attributes != (const xmlChar **) NULL)
3556 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3558 keyword=(const char *) attributes[i++];
3559 attribute=InterpretImageProperties(msl_info->image_info[n],
3560 msl_info->attributes[n],(const char *) attributes[i]);
3561 CloneString(&value,attribute);
3567 if (LocaleCompare(keyword,"dither") == 0)
3569 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3572 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3574 dither=(MagickBooleanType) option;
3577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3584 if (LocaleCompare(keyword,"image") == 0)
3585 for (j=0; j < msl_info->n; j++)
3590 attribute=GetImageProperty(msl_info->attributes[j],"id");
3591 if ((attribute != (const char *) NULL) &&
3592 (LocaleCompare(attribute,value) == 0))
3594 affinity_image=CloneImage(msl_info->image[j],0,0,
3595 MagickFalse,&exception);
3603 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3609 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3610 quantize_info->dither=dither;
3611 (void) RemapImages(quantize_info,msl_info->image[n],
3613 quantize_info=DestroyQuantizeInfo(quantize_info);
3614 affinity_image=DestroyImage(affinity_image);
3617 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3629 Matte floodfill image.
3632 if (msl_info->image[n] == (Image *) NULL)
3634 ThrowMSLException(OptionError,"NoImagesDefined",
3635 (const char *) tag);
3638 SetGeometry(msl_info->image[n],&geometry);
3639 paint_method=FloodfillMethod;
3640 if (attributes != (const xmlChar **) NULL)
3641 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3643 keyword=(const char *) attributes[i++];
3644 attribute=InterpretImageProperties(msl_info->image_info[n],
3645 msl_info->attributes[n],(const char *) attributes[i]);
3646 CloneString(&value,attribute);
3652 if (LocaleCompare(keyword,"bordercolor") == 0)
3654 (void) QueryMagickColor(value,&target,&exception);
3655 paint_method=FillToBorderMethod;
3658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3665 if (LocaleCompare(keyword,"fuzz") == 0)
3667 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3678 if (LocaleCompare(keyword,"geometry") == 0)
3680 flags=ParsePageGeometry(msl_info->image[n],value,
3681 &geometry,&exception);
3682 if ((flags & HeightValue) == 0)
3683 geometry.height=geometry.width;
3684 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3685 geometry.x,geometry.y,&target,&exception);
3688 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3695 if (LocaleCompare(keyword,"opacity") == 0)
3697 opacity=InterpretLocaleValue(value,(char **) NULL);
3700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3707 if (LocaleCompare(keyword,"x") == 0)
3709 geometry.x=StringToLong(value);
3710 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3711 geometry.x,geometry.y,&target,&exception);
3714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3721 if (LocaleCompare(keyword,"y") == 0)
3723 geometry.y=StringToLong(value);
3724 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3725 geometry.x,geometry.y,&target,&exception);
3728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3740 draw_info=CloneDrawInfo(msl_info->image_info[n],
3741 msl_info->draw_info[n]);
3742 draw_info->fill.alpha=ClampToQuantum(opacity);
3743 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3744 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3745 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3746 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
3747 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
3748 draw_info=DestroyDrawInfo(draw_info);
3751 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3757 Median-filter image.
3759 if (msl_info->image[n] == (Image *) NULL)
3761 ThrowMSLException(OptionError,"NoImagesDefined",
3762 (const char *) tag);
3765 if (attributes != (const xmlChar **) NULL)
3766 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3768 keyword=(const char *) attributes[i++];
3769 attribute=InterpretImageProperties(msl_info->image_info[n],
3770 msl_info->attributes[n],(const char *) attributes[i]);
3771 CloneString(&value,attribute);
3777 if (LocaleCompare(keyword,"geometry") == 0)
3779 flags=ParseGeometry(value,&geometry_info);
3780 if ((flags & SigmaValue) == 0)
3781 geometry_info.sigma=1.0;
3784 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3791 if (LocaleCompare(keyword,"radius") == 0)
3793 geometry_info.rho=InterpretLocaleValue(value,
3797 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3809 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3810 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3811 &msl_info->image[n]->exception);
3812 if (median_image == (Image *) NULL)
3814 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3815 msl_info->image[n]=median_image;
3818 if (LocaleCompare((const char *) tag,"minify") == 0)
3826 if (msl_info->image[n] == (Image *) NULL)
3828 ThrowMSLException(OptionError,"NoImagesDefined",
3829 (const char *) tag);
3832 if (attributes != (const xmlChar **) NULL)
3833 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3835 keyword=(const char *) attributes[i++];
3836 attribute=InterpretImageProperties(msl_info->image_info[n],
3837 msl_info->attributes[n],(const char *) attributes[i]);
3838 CloneString(&value,attribute);
3839 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3841 minify_image=MinifyImage(msl_info->image[n],
3842 &msl_info->image[n]->exception);
3843 if (minify_image == (Image *) NULL)
3845 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3846 msl_info->image[n]=minify_image;
3849 if (LocaleCompare((const char *) tag,"msl") == 0 )
3851 if (LocaleCompare((const char *) tag,"modulate") == 0)
3854 modulate[MaxTextExtent];
3859 if (msl_info->image[n] == (Image *) NULL)
3861 ThrowMSLException(OptionError,"NoImagesDefined",
3862 (const char *) tag);
3865 geometry_info.rho=100.0;
3866 geometry_info.sigma=100.0;
3867 geometry_info.xi=100.0;
3868 if (attributes != (const xmlChar **) NULL)
3869 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3871 keyword=(const char *) attributes[i++];
3872 attribute=InterpretImageProperties(msl_info->image_info[n],
3873 msl_info->attributes[n],(const char *) attributes[i]);
3874 CloneString(&value,attribute);
3880 if (LocaleCompare(keyword,"blackness") == 0)
3882 geometry_info.rho=InterpretLocaleValue(value,
3886 if (LocaleCompare(keyword,"brightness") == 0)
3888 geometry_info.rho=InterpretLocaleValue(value,
3892 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3899 if (LocaleCompare(keyword,"factor") == 0)
3901 flags=ParseGeometry(value,&geometry_info);
3904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3911 if (LocaleCompare(keyword,"hue") == 0)
3913 geometry_info.xi=InterpretLocaleValue(value,
3917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3924 if (LocaleCompare(keyword,"lightness") == 0)
3926 geometry_info.rho=InterpretLocaleValue(value,
3930 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3937 if (LocaleCompare(keyword,"saturation") == 0)
3939 geometry_info.sigma=InterpretLocaleValue(value,
3943 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3950 if (LocaleCompare(keyword,"whiteness") == 0)
3952 geometry_info.sigma=InterpretLocaleValue(value,
3956 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3962 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3968 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
3969 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3970 (void) ModulateImage(msl_info->image[n],modulate,
3971 &msl_info->image[n]->exception);
3974 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3979 if (LocaleCompare((const char *) tag,"negate") == 0)
3987 if (msl_info->image[n] == (Image *) NULL)
3989 ThrowMSLException(OptionError,"NoImagesDefined",
3990 (const char *) tag);
3994 if (attributes != (const xmlChar **) NULL)
3995 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3997 keyword=(const char *) attributes[i++];
3998 attribute=InterpretImageProperties(msl_info->image_info[n],
3999 msl_info->attributes[n],(const char *) attributes[i]);
4000 CloneString(&value,attribute);
4006 if (LocaleCompare(keyword,"channel") == 0)
4008 option=ParseChannelOption(value);
4010 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4012 channel=(ChannelType) option;
4015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4022 if (LocaleCompare(keyword,"gray") == 0)
4024 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4027 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4029 gray=(MagickBooleanType) option;
4032 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4038 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4044 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4045 (void) NegateImage(msl_info->image[n],gray,
4046 &msl_info->image[n]->exception);
4047 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4050 if (LocaleCompare((const char *) tag,"normalize") == 0)
4055 if (msl_info->image[n] == (Image *) NULL)
4057 ThrowMSLException(OptionError,"NoImagesDefined",
4058 (const char *) tag);
4061 if (attributes != (const xmlChar **) NULL)
4062 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4064 keyword=(const char *) attributes[i++];
4065 attribute=InterpretImageProperties(msl_info->image_info[n],
4066 msl_info->attributes[n],(const char *) attributes[i]);
4067 CloneString(&value,attribute);
4073 if (LocaleCompare(keyword,"channel") == 0)
4075 option=ParseChannelOption(value);
4077 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4079 channel=(ChannelType) option;
4082 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4088 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4094 (void) NormalizeImage(msl_info->image[n],
4095 &msl_info->image[n]->exception);
4098 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4103 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4111 if (msl_info->image[n] == (Image *) NULL)
4113 ThrowMSLException(OptionError,"NoImagesDefined",
4114 (const char *) tag);
4117 if (attributes != (const xmlChar **) NULL)
4118 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4120 keyword=(const char *) attributes[i++];
4121 attribute=InterpretImageProperties(msl_info->image_info[n],
4122 msl_info->attributes[n],(const char *) attributes[i]);
4123 CloneString(&value,attribute);
4129 if (LocaleCompare(keyword,"geometry") == 0)
4131 flags=ParseGeometry(value,&geometry_info);
4132 if ((flags & SigmaValue) == 0)
4133 geometry_info.sigma=1.0;
4136 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4143 if (LocaleCompare(keyword,"radius") == 0)
4145 geometry_info.rho=InterpretLocaleValue(value,
4149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4161 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4162 geometry_info.sigma,&msl_info->image[n]->exception);
4163 if (paint_image == (Image *) NULL)
4165 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4166 msl_info->image[n]=paint_image;
4169 if (LocaleCompare((const char *) tag,"opaque") == 0)
4178 if (msl_info->image[n] == (Image *) NULL)
4180 ThrowMSLException(OptionError,"NoImagesDefined",
4181 (const char *) tag);
4184 (void) QueryMagickColor("none",&target,&exception);
4185 (void) QueryMagickColor("none",&fill_color,&exception);
4186 if (attributes != (const xmlChar **) NULL)
4187 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4189 keyword=(const char *) attributes[i++];
4190 attribute=InterpretImageProperties(msl_info->image_info[n],
4191 msl_info->attributes[n],(const char *) attributes[i]);
4192 CloneString(&value,attribute);
4198 if (LocaleCompare(keyword,"channel") == 0)
4200 option=ParseChannelOption(value);
4202 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4204 channel=(ChannelType) option;
4207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4214 if (LocaleCompare(keyword,"fill") == 0)
4216 (void) QueryMagickColor(value,&fill_color,&exception);
4219 if (LocaleCompare(keyword,"fuzz") == 0)
4221 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4225 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4237 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4238 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4239 MagickFalse,&msl_info->image[n]->exception);
4240 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4243 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4248 if (LocaleCompare((const char *) tag,"print") == 0)
4250 if (attributes == (const xmlChar **) NULL)
4252 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4254 keyword=(const char *) attributes[i++];
4255 attribute=InterpretImageProperties(msl_info->image_info[n],
4256 msl_info->attributes[n],(const char *) attributes[i]);
4257 CloneString(&value,attribute);
4263 if (LocaleCompare(keyword,"output") == 0)
4265 (void) FormatLocaleFile(stdout,"%s",value);
4268 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4273 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4280 if (LocaleCompare((const char *) tag, "profile") == 0)
4282 if (msl_info->image[n] == (Image *) NULL)
4284 ThrowMSLException(OptionError,"NoImagesDefined",
4285 (const char *) tag);
4288 if (attributes == (const xmlChar **) NULL)
4290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4304 keyword=(const char *) attributes[i++];
4305 attribute=InterpretImageProperties(msl_info->image_info[n],
4306 msl_info->attributes[n],(const char *) attributes[i]);
4307 CloneString(&value,attribute);
4308 if (*keyword == '+')
4311 Remove a profile from the image.
4313 (void) ProfileImage(msl_info->image[n],keyword,
4314 (const unsigned char *) NULL,0,MagickTrue);
4318 Associate a profile with the image.
4320 profile_info=CloneImageInfo(msl_info->image_info[n]);
4321 profile=GetImageProfile(msl_info->image[n],"iptc");
4322 if (profile != (StringInfo *) NULL)
4323 profile_info->profile=(void *) CloneStringInfo(profile);
4324 profile_image=GetImageCache(profile_info,keyword,&exception);
4325 profile_info=DestroyImageInfo(profile_info);
4326 if (profile_image == (Image *) NULL)
4329 name[MaxTextExtent],
4330 filename[MaxTextExtent];
4338 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4339 (void) CopyMagickString(name,keyword,MaxTextExtent);
4340 for (p=filename; *p != '\0'; p++)
4341 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4342 (IsPathAccessible(keyword) == MagickFalse))
4348 Look for profile name (e.g. name:profile).
4350 (void) CopyMagickString(name,filename,(size_t)
4352 for (q=filename; *q != '\0'; q++)
4356 profile=FileToStringInfo(filename,~0UL,&exception);
4357 if (profile != (StringInfo *) NULL)
4359 (void) ProfileImage(msl_info->image[n],name,
4360 GetStringInfoDatum(profile),(size_t)
4361 GetStringInfoLength(profile),MagickFalse);
4362 profile=DestroyStringInfo(profile);
4366 ResetImageProfileIterator(profile_image);
4367 name=GetNextImageProfile(profile_image);
4368 while (name != (const char *) NULL)
4370 profile=GetImageProfile(profile_image,name);
4371 if (profile != (StringInfo *) NULL)
4372 (void) ProfileImage(msl_info->image[n],name,
4373 GetStringInfoDatum(profile),(size_t)
4374 GetStringInfoLength(profile),MagickFalse);
4375 name=GetNextImageProfile(profile_image);
4377 profile_image=DestroyImage(profile_image);
4381 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4386 if (LocaleCompare((const char *) tag,"quantize") == 0)
4394 if (msl_info->image[n] == (Image *) NULL)
4396 ThrowMSLException(OptionError,"NoImagesDefined",
4397 (const char *) tag);
4400 GetQuantizeInfo(&quantize_info);
4401 if (attributes != (const xmlChar **) NULL)
4402 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4404 keyword=(const char *) attributes[i++];
4405 attribute=InterpretImageProperties(msl_info->image_info[n],
4406 msl_info->attributes[n],(const char *) attributes[i]);
4407 CloneString(&value,attribute);
4413 if (LocaleCompare(keyword,"colors") == 0)
4415 quantize_info.number_colors=StringToLong(value);
4418 if (LocaleCompare(keyword,"colorspace") == 0)
4420 option=ParseCommandOption(MagickColorspaceOptions,
4423 ThrowMSLException(OptionError,
4424 "UnrecognizedColorspaceType",value);
4425 quantize_info.colorspace=(ColorspaceType) option;
4428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4435 if (LocaleCompare(keyword,"dither") == 0)
4437 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4440 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4442 quantize_info.dither=(MagickBooleanType) option;
4445 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4452 if (LocaleCompare(keyword,"measure") == 0)
4454 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4457 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4459 quantize_info.measure_error=(MagickBooleanType) option;
4462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4469 if (LocaleCompare(keyword,"treedepth") == 0)
4471 quantize_info.tree_depth=StringToLong(value);
4474 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4480 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4486 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4489 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4492 text[MaxTextExtent];
4503 draw_info=CloneDrawInfo(msl_info->image_info[n],
4504 msl_info->draw_info[n]);
4506 current=draw_info->affine;
4507 GetAffineMatrix(&affine);
4508 if (attributes != (const xmlChar **) NULL)
4509 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4511 keyword=(const char *) attributes[i++];
4512 attribute=InterpretImageProperties(msl_info->image_info[n],
4513 msl_info->attributes[n],(const char *) attributes[i]);
4514 CloneString(&value,attribute);
4520 if (LocaleCompare(keyword,"affine") == 0)
4526 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4529 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4532 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4535 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4538 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4541 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4544 if (LocaleCompare(keyword,"align") == 0)
4546 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4549 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4551 draw_info->align=(AlignType) option;
4554 if (LocaleCompare(keyword,"antialias") == 0)
4556 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4559 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4561 draw_info->stroke_antialias=(MagickBooleanType) option;
4562 draw_info->text_antialias=(MagickBooleanType) option;
4565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4572 if (LocaleCompare(keyword,"density") == 0)
4574 CloneString(&draw_info->density,value);
4577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4584 if (LocaleCompare(keyword,"encoding") == 0)
4586 CloneString(&draw_info->encoding,value);
4589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4596 if (LocaleCompare(keyword, "fill") == 0)
4598 (void) QueryColorDatabase(value,&draw_info->fill,
4602 if (LocaleCompare(keyword,"family") == 0)
4604 CloneString(&draw_info->family,value);
4607 if (LocaleCompare(keyword,"font") == 0)
4609 CloneString(&draw_info->font,value);
4612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4619 if (LocaleCompare(keyword,"geometry") == 0)
4621 flags=ParsePageGeometry(msl_info->image[n],value,
4622 &geometry,&exception);
4623 if ((flags & HeightValue) == 0)
4624 geometry.height=geometry.width;
4627 if (LocaleCompare(keyword,"gravity") == 0)
4629 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4632 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4634 draw_info->gravity=(GravityType) option;
4637 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4644 if (LocaleCompare(keyword,"pointsize") == 0)
4646 draw_info->pointsize=InterpretLocaleValue(value,
4650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4657 if (LocaleCompare(keyword,"rotate") == 0)
4659 angle=InterpretLocaleValue(value,(char **) NULL);
4660 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4661 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4662 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4663 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4673 if (LocaleCompare(keyword,"scale") == 0)
4675 flags=ParseGeometry(value,&geometry_info);
4676 if ((flags & SigmaValue) == 0)
4677 geometry_info.sigma=1.0;
4678 affine.sx=geometry_info.rho;
4679 affine.sy=geometry_info.sigma;
4682 if (LocaleCompare(keyword,"skewX") == 0)
4684 angle=InterpretLocaleValue(value,(char **) NULL);
4685 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4688 if (LocaleCompare(keyword,"skewY") == 0)
4690 angle=InterpretLocaleValue(value,(char **) NULL);
4691 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4694 if (LocaleCompare(keyword,"stretch") == 0)
4696 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4699 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4701 draw_info->stretch=(StretchType) option;
4704 if (LocaleCompare(keyword, "stroke") == 0)
4706 (void) QueryColorDatabase(value,&draw_info->stroke,
4710 if (LocaleCompare(keyword,"strokewidth") == 0)
4712 draw_info->stroke_width=StringToLong(value);
4715 if (LocaleCompare(keyword,"style") == 0)
4717 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4720 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4722 draw_info->style=(StyleType) option;
4725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4732 if (LocaleCompare(keyword,"text") == 0)
4734 CloneString(&draw_info->text,value);
4737 if (LocaleCompare(keyword,"translate") == 0)
4739 flags=ParseGeometry(value,&geometry_info);
4740 if ((flags & SigmaValue) == 0)
4741 geometry_info.sigma=1.0;
4742 affine.tx=geometry_info.rho;
4743 affine.ty=geometry_info.sigma;
4746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4753 if (LocaleCompare(keyword, "undercolor") == 0)
4755 (void) QueryColorDatabase(value,&draw_info->undercolor,
4759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4766 if (LocaleCompare(keyword,"weight") == 0)
4768 draw_info->weight=StringToLong(value);
4771 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4778 if (LocaleCompare(keyword,"x") == 0)
4780 geometry.x=StringToLong(value);
4783 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4790 if (LocaleCompare(keyword,"y") == 0)
4792 geometry.y=StringToLong(value);
4795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4801 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4807 (void) FormatLocaleString(text,MaxTextExtent,
4808 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4809 geometry.height,(double) geometry.x,(double) geometry.y);
4810 CloneString(&draw_info->geometry,text);
4811 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4812 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4813 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4814 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4815 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4817 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4819 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4820 if (status != MagickFalse)
4825 image=msl_info->attributes[n];
4826 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4827 "%g",metrics.pixels_per_em.x);
4828 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4829 "%g",metrics.pixels_per_em.y);
4830 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4832 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4834 FormatImageProperty(image,"msl:font-metrics.width","%g",
4836 FormatImageProperty(image,"msl:font-metrics.height","%g",
4838 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4839 metrics.max_advance);
4840 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4842 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4844 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4846 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4848 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4850 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4853 draw_info=DestroyDrawInfo(draw_info);
4856 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4861 if (LocaleCompare((const char *) tag,"raise") == 0)
4869 if (msl_info->image[n] == (Image *) NULL)
4871 ThrowMSLException(OptionError,"NoImagesDefined",
4872 (const char *) tag);
4876 SetGeometry(msl_info->image[n],&geometry);
4877 if (attributes != (const xmlChar **) NULL)
4878 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4880 keyword=(const char *) attributes[i++];
4881 attribute=InterpretImageProperties(msl_info->image_info[n],
4882 msl_info->attributes[n],(const char *) attributes[i]);
4883 CloneString(&value,attribute);
4889 if (LocaleCompare(keyword,"geometry") == 0)
4891 flags=ParsePageGeometry(msl_info->image[n],value,
4892 &geometry,&exception);
4893 if ((flags & HeightValue) == 0)
4894 geometry.height=geometry.width;
4897 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4904 if (LocaleCompare(keyword,"height") == 0)
4906 geometry.height=StringToLong(value);
4909 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4916 if (LocaleCompare(keyword,"raise") == 0)
4918 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4921 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4923 raise=(MagickBooleanType) option;
4926 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4933 if (LocaleCompare(keyword,"width") == 0)
4935 geometry.width=StringToLong(value);
4938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4950 (void) RaiseImage(msl_info->image[n],&geometry,raise,
4951 &msl_info->image[n]->exception);
4954 if (LocaleCompare((const char *) tag,"read") == 0)
4956 if (attributes == (const xmlChar **) NULL)
4958 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4960 keyword=(const char *) attributes[i++];
4961 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4962 msl_info->attributes[n],(const char *) attributes[i]));
4968 if (LocaleCompare(keyword,"filename") == 0)
4973 (void) CopyMagickString(msl_info->image_info[n]->filename,
4974 value,MaxTextExtent);
4975 image=ReadImage(msl_info->image_info[n],&exception);
4976 CatchException(&exception);
4977 if (image == (Image *) NULL)
4979 AppendImageToList(&msl_info->image[n],image);
4982 (void) SetMSLAttributes(msl_info,keyword,value);
4987 (void) SetMSLAttributes(msl_info,keyword,value);
4994 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5002 if (msl_info->image[n] == (Image *) NULL)
5004 ThrowMSLException(OptionError,"NoImagesDefined",
5005 (const char *) tag);
5008 if (attributes != (const xmlChar **) NULL)
5009 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5011 keyword=(const char *) attributes[i++];
5012 attribute=InterpretImageProperties(msl_info->image_info[n],
5013 msl_info->attributes[n],(const char *) attributes[i]);
5014 CloneString(&value,attribute);
5020 if (LocaleCompare(keyword,"geometry") == 0)
5022 flags=ParseGeometry(value,&geometry_info);
5023 if ((flags & SigmaValue) == 0)
5024 geometry_info.sigma=1.0;
5027 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5034 if (LocaleCompare(keyword,"radius") == 0)
5036 geometry_info.rho=InterpretLocaleValue(value,
5040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5046 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5052 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5053 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5054 &msl_info->image[n]->exception);
5055 if (paint_image == (Image *) NULL)
5057 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5058 msl_info->image[n]=paint_image;
5061 else if (LocaleCompare((const char *) tag,"repage") == 0)
5063 /* init the values */
5064 width=msl_info->image[n]->page.width;
5065 height=msl_info->image[n]->page.height;
5066 x=msl_info->image[n]->page.x;
5067 y=msl_info->image[n]->page.y;
5069 if (msl_info->image[n] == (Image *) NULL)
5071 ThrowMSLException(OptionError,"NoImagesDefined",
5072 (const char *) tag);
5075 if (attributes == (const xmlChar **) NULL)
5077 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5079 keyword=(const char *) attributes[i++];
5080 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5081 msl_info->attributes[n],(const char *) attributes[i]));
5087 if (LocaleCompare(keyword,"geometry") == 0)
5095 flags=ParseAbsoluteGeometry(value,&geometry);
5096 if ((flags & WidthValue) != 0)
5098 if ((flags & HeightValue) == 0)
5099 geometry.height=geometry.width;
5100 width=geometry.width;
5101 height=geometry.height;
5103 if ((flags & AspectValue) != 0)
5105 if ((flags & XValue) != 0)
5107 if ((flags & YValue) != 0)
5112 if ((flags & XValue) != 0)
5115 if ((width == 0) && (geometry.x > 0))
5116 width=msl_info->image[n]->columns+geometry.x;
5118 if ((flags & YValue) != 0)
5121 if ((height == 0) && (geometry.y > 0))
5122 height=msl_info->image[n]->rows+geometry.y;
5127 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5133 if (LocaleCompare(keyword,"height") == 0)
5135 height = StringToLong( value );
5138 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5144 if (LocaleCompare(keyword,"width") == 0)
5146 width = StringToLong( value );
5149 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5155 if (LocaleCompare(keyword,"x") == 0)
5157 x = StringToLong( value );
5160 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5166 if (LocaleCompare(keyword,"y") == 0)
5168 y = StringToLong( value );
5171 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5176 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5182 msl_info->image[n]->page.width=width;
5183 msl_info->image[n]->page.height=height;
5184 msl_info->image[n]->page.x=x;
5185 msl_info->image[n]->page.y=y;
5188 else if (LocaleCompare((const char *) tag,"resample") == 0)
5194 if (msl_info->image[n] == (Image *) NULL)
5196 ThrowMSLException(OptionError,"NoImagesDefined",
5197 (const char *) tag);
5200 if (attributes == (const xmlChar **) NULL)
5202 x_resolution=DefaultResolution;
5203 y_resolution=DefaultResolution;
5204 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5206 keyword=(const char *) attributes[i++];
5207 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5208 msl_info->attributes[n],(const char *) attributes[i]));
5213 if (LocaleCompare(keyword,"blur") == 0)
5215 msl_info->image[n]->blur=InterpretLocaleValue(value,
5219 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5225 if (LocaleCompare(keyword,"geometry") == 0)
5230 flags=ParseGeometry(value,&geometry_info);
5231 if ((flags & SigmaValue) == 0)
5232 geometry_info.sigma*=geometry_info.rho;
5233 x_resolution=geometry_info.rho;
5234 y_resolution=geometry_info.sigma;
5237 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5243 if (LocaleCompare(keyword,"x-resolution") == 0)
5245 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5248 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5254 if (LocaleCompare(keyword,"y-resolution") == 0)
5256 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5259 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5264 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5280 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5282 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5283 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5284 msl_info->image[n]->x_resolution))+0.5);
5285 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5286 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5287 msl_info->image[n]->y_resolution))+0.5);
5288 resample_image=ResizeImage(msl_info->image[n],width,height,
5289 msl_info->image[n]->filter,msl_info->image[n]->blur,
5290 &msl_info->image[n]->exception);
5291 if (resample_image == (Image *) NULL)
5293 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5294 msl_info->image[n]=resample_image;
5298 if (LocaleCompare((const char *) tag,"resize") == 0)
5312 if (msl_info->image[n] == (Image *) NULL)
5314 ThrowMSLException(OptionError,"NoImagesDefined",
5315 (const char *) tag);
5318 filter=UndefinedFilter;
5320 if (attributes != (const xmlChar **) NULL)
5321 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5323 keyword=(const char *) attributes[i++];
5324 attribute=InterpretImageProperties(msl_info->image_info[n],
5325 msl_info->attributes[n],(const char *) attributes[i]);
5326 CloneString(&value,attribute);
5332 if (LocaleCompare(keyword,"filter") == 0)
5334 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5337 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5339 filter=(FilterTypes) option;
5342 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5349 if (LocaleCompare(keyword,"geometry") == 0)
5351 flags=ParseRegionGeometry(msl_info->image[n],value,
5352 &geometry,&exception);
5355 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5362 if (LocaleCompare(keyword,"height") == 0)
5364 geometry.height=StringToUnsignedLong(value);
5367 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5374 if (LocaleCompare(keyword,"support") == 0)
5376 blur=InterpretLocaleValue(value,(char **) NULL);
5379 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5386 if (LocaleCompare(keyword,"width") == 0)
5388 geometry.width=StringToLong(value);
5391 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5397 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5403 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5404 geometry.height,filter,blur,&msl_info->image[n]->exception);
5405 if (resize_image == (Image *) NULL)
5407 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5408 msl_info->image[n]=resize_image;
5411 if (LocaleCompare((const char *) tag,"roll") == 0)
5419 if (msl_info->image[n] == (Image *) NULL)
5421 ThrowMSLException(OptionError,"NoImagesDefined",
5422 (const char *) tag);
5425 SetGeometry(msl_info->image[n],&geometry);
5426 if (attributes != (const xmlChar **) NULL)
5427 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5429 keyword=(const char *) attributes[i++];
5430 attribute=InterpretImageProperties(msl_info->image_info[n],
5431 msl_info->attributes[n],(const char *) attributes[i]);
5432 CloneString(&value,attribute);
5438 if (LocaleCompare(keyword,"geometry") == 0)
5440 flags=ParsePageGeometry(msl_info->image[n],value,
5441 &geometry,&exception);
5442 if ((flags & HeightValue) == 0)
5443 geometry.height=geometry.width;
5446 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5453 if (LocaleCompare(keyword,"x") == 0)
5455 geometry.x=StringToLong(value);
5458 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5465 if (LocaleCompare(keyword,"y") == 0)
5467 geometry.y=StringToLong(value);
5470 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5476 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5482 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5483 &msl_info->image[n]->exception);
5484 if (roll_image == (Image *) NULL)
5486 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5487 msl_info->image[n]=roll_image;
5490 else if (LocaleCompare((const char *) tag,"roll") == 0)
5492 /* init the values */
5493 width=msl_info->image[n]->columns;
5494 height=msl_info->image[n]->rows;
5497 if (msl_info->image[n] == (Image *) NULL)
5499 ThrowMSLException(OptionError,"NoImagesDefined",
5500 (const char *) tag);
5503 if (attributes == (const xmlChar **) NULL)
5505 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5507 keyword=(const char *) attributes[i++];
5508 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5509 msl_info->attributes[n],(const char *) attributes[i]));
5515 if (LocaleCompare(keyword,"geometry") == 0)
5517 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5520 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5526 if (LocaleCompare(keyword,"x") == 0)
5528 x = StringToLong( value );
5531 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5537 if (LocaleCompare(keyword,"y") == 0)
5539 y = StringToLong( value );
5542 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5547 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5560 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5561 if (newImage == (Image *) NULL)
5563 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5564 msl_info->image[n]=newImage;
5569 if (LocaleCompare((const char *) tag,"rotate") == 0)
5577 if (msl_info->image[n] == (Image *) NULL)
5579 ThrowMSLException(OptionError,"NoImagesDefined",
5580 (const char *) tag);
5583 if (attributes != (const xmlChar **) NULL)
5584 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5586 keyword=(const char *) attributes[i++];
5587 attribute=InterpretImageProperties(msl_info->image_info[n],
5588 msl_info->attributes[n],(const char *) attributes[i]);
5589 CloneString(&value,attribute);
5595 if (LocaleCompare(keyword,"degrees") == 0)
5597 geometry_info.rho=InterpretLocaleValue(value,
5601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5608 if (LocaleCompare(keyword,"geometry") == 0)
5610 flags=ParseGeometry(value,&geometry_info);
5611 if ((flags & SigmaValue) == 0)
5612 geometry_info.sigma=1.0;
5615 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5621 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5627 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5628 &msl_info->image[n]->exception);
5629 if (rotate_image == (Image *) NULL)
5631 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5632 msl_info->image[n]=rotate_image;
5635 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5637 /* init the values */
5640 if (msl_info->image[n] == (Image *) NULL)
5642 ThrowMSLException(OptionError,"NoImagesDefined",
5643 (const char *) tag);
5646 if (attributes == (const xmlChar **) NULL)
5648 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5650 keyword=(const char *) attributes[i++];
5651 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5652 msl_info->attributes[n],(const char *) attributes[i]));
5658 if (LocaleCompare(keyword,"degrees") == 0)
5660 degrees = InterpretLocaleValue(value,(char **) NULL);
5663 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5668 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5681 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5682 if (newImage == (Image *) NULL)
5684 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5685 msl_info->image[n]=newImage;
5690 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5695 if (LocaleCompare((const char *) tag,"sample") == 0)
5703 if (msl_info->image[n] == (Image *) NULL)
5705 ThrowMSLException(OptionError,"NoImagesDefined",
5706 (const char *) tag);
5709 if (attributes != (const xmlChar **) NULL)
5710 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5712 keyword=(const char *) attributes[i++];
5713 attribute=InterpretImageProperties(msl_info->image_info[n],
5714 msl_info->attributes[n],(const char *) attributes[i]);
5715 CloneString(&value,attribute);
5721 if (LocaleCompare(keyword,"geometry") == 0)
5723 flags=ParseRegionGeometry(msl_info->image[n],value,
5724 &geometry,&exception);
5727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5734 if (LocaleCompare(keyword,"height") == 0)
5736 geometry.height=StringToUnsignedLong(value);
5739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5746 if (LocaleCompare(keyword,"width") == 0)
5748 geometry.width=StringToLong(value);
5751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5757 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5763 sample_image=SampleImage(msl_info->image[n],geometry.width,
5764 geometry.height,&msl_info->image[n]->exception);
5765 if (sample_image == (Image *) NULL)
5767 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5768 msl_info->image[n]=sample_image;
5771 if (LocaleCompare((const char *) tag,"scale") == 0)
5779 if (msl_info->image[n] == (Image *) NULL)
5781 ThrowMSLException(OptionError,"NoImagesDefined",
5782 (const char *) tag);
5785 if (attributes != (const xmlChar **) NULL)
5786 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5788 keyword=(const char *) attributes[i++];
5789 attribute=InterpretImageProperties(msl_info->image_info[n],
5790 msl_info->attributes[n],(const char *) attributes[i]);
5791 CloneString(&value,attribute);
5797 if (LocaleCompare(keyword,"geometry") == 0)
5799 flags=ParseRegionGeometry(msl_info->image[n],value,
5800 &geometry,&exception);
5803 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5810 if (LocaleCompare(keyword,"height") == 0)
5812 geometry.height=StringToUnsignedLong(value);
5815 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5822 if (LocaleCompare(keyword,"width") == 0)
5824 geometry.width=StringToLong(value);
5827 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5833 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5839 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5840 geometry.height,&msl_info->image[n]->exception);
5841 if (scale_image == (Image *) NULL)
5843 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5844 msl_info->image[n]=scale_image;
5847 if (LocaleCompare((const char *) tag,"segment") == 0)
5858 if (msl_info->image[n] == (Image *) NULL)
5860 ThrowMSLException(OptionError,"NoImagesDefined",
5861 (const char *) tag);
5864 geometry_info.rho=1.0;
5865 geometry_info.sigma=1.5;
5866 colorspace=RGBColorspace;
5867 verbose=MagickFalse;
5868 if (attributes != (const xmlChar **) NULL)
5869 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5871 keyword=(const char *) attributes[i++];
5872 attribute=InterpretImageProperties(msl_info->image_info[n],
5873 msl_info->attributes[n],(const char *) attributes[i]);
5874 CloneString(&value,attribute);
5880 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5882 geometry_info.rho=InterpretLocaleValue(value,
5886 if (LocaleCompare(keyword,"colorspace") == 0)
5888 option=ParseCommandOption(MagickColorspaceOptions,
5891 ThrowMSLException(OptionError,
5892 "UnrecognizedColorspaceType",value);
5893 colorspace=(ColorspaceType) option;
5896 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5903 if (LocaleCompare(keyword,"geometry") == 0)
5905 flags=ParseGeometry(value,&geometry_info);
5906 if ((flags & SigmaValue) == 0)
5907 geometry_info.sigma=1.5;
5910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5917 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5919 geometry_info.sigma=InterpretLocaleValue(value,
5923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5929 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5935 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5936 geometry_info.rho,geometry_info.sigma);
5939 else if (LocaleCompare((const char *) tag, "set") == 0)
5941 if (msl_info->image[n] == (Image *) NULL)
5943 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5947 if (attributes == (const xmlChar **) NULL)
5949 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5951 keyword=(const char *) attributes[i++];
5952 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5953 msl_info->attributes[n],(const char *) attributes[i]));
5959 if (LocaleCompare(keyword,"clip-mask") == 0)
5961 for (j=0; j < msl_info->n; j++)
5966 property=GetImageProperty(msl_info->attributes[j],"id");
5967 if (LocaleCompare(property,value) == 0)
5969 SetImageMask(msl_info->image[n],msl_info->image[j]);
5975 if (LocaleCompare(keyword,"clip-path") == 0)
5977 for (j=0; j < msl_info->n; j++)
5982 property=GetImageProperty(msl_info->attributes[j],"id");
5983 if (LocaleCompare(property,value) == 0)
5985 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5991 if (LocaleCompare(keyword,"colorspace") == 0)
5996 colorspace=(ColorspaceType) ParseCommandOption(
5997 MagickColorspaceOptions,MagickFalse,value);
5999 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6001 (void) TransformImageColorspace(msl_info->image[n],
6002 (ColorspaceType) colorspace);
6005 (void) SetMSLAttributes(msl_info,keyword,value);
6006 (void) SetImageProperty(msl_info->image[n],keyword,value);
6012 if (LocaleCompare(keyword,"density") == 0)
6014 flags=ParseGeometry(value,&geometry_info);
6015 msl_info->image[n]->x_resolution=geometry_info.rho;
6016 msl_info->image[n]->y_resolution=geometry_info.sigma;
6017 if ((flags & SigmaValue) == 0)
6018 msl_info->image[n]->y_resolution=
6019 msl_info->image[n]->x_resolution;
6022 (void) SetMSLAttributes(msl_info,keyword,value);
6023 (void) SetImageProperty(msl_info->image[n],keyword,value);
6029 if (LocaleCompare(keyword, "opacity") == 0)
6031 ssize_t opac = OpaqueAlpha,
6032 len = (ssize_t) strlen( value );
6034 if (value[len-1] == '%') {
6036 (void) CopyMagickString(tmp,value,len);
6037 opac = StringToLong( tmp );
6038 opac = (int)(QuantumRange * ((float)opac/100));
6040 opac = StringToLong( value );
6041 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6044 (void) SetMSLAttributes(msl_info,keyword,value);
6045 (void) SetImageProperty(msl_info->image[n],keyword,value);
6051 if (LocaleCompare(keyword, "page") == 0)
6054 page[MaxTextExtent];
6065 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6066 image_option=GetImageOption(msl_info->image_info[n],"page");
6067 if (image_option != (const char *) NULL)
6068 flags=ParseAbsoluteGeometry(image_option,&geometry);
6069 flags=ParseAbsoluteGeometry(value,&geometry);
6070 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6071 (double) geometry.width,(double) geometry.height);
6072 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6073 (void) FormatLocaleString(page,MaxTextExtent,
6074 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6075 (double) geometry.height,(double) geometry.x,(double)
6077 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6078 msl_info->image_info[n]->page=GetPageGeometry(page);
6081 (void) SetMSLAttributes(msl_info,keyword,value);
6082 (void) SetImageProperty(msl_info->image[n],keyword,value);
6087 (void) SetMSLAttributes(msl_info,keyword,value);
6088 (void) SetImageProperty(msl_info->image[n],keyword,value);
6095 if (LocaleCompare((const char *) tag,"shade") == 0)
6106 if (msl_info->image[n] == (Image *) NULL)
6108 ThrowMSLException(OptionError,"NoImagesDefined",
6109 (const char *) tag);
6113 if (attributes != (const xmlChar **) NULL)
6114 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6116 keyword=(const char *) attributes[i++];
6117 attribute=InterpretImageProperties(msl_info->image_info[n],
6118 msl_info->attributes[n],(const char *) attributes[i]);
6119 CloneString(&value,attribute);
6125 if (LocaleCompare(keyword,"azimuth") == 0)
6127 geometry_info.rho=InterpretLocaleValue(value,
6131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6138 if (LocaleCompare(keyword,"elevation") == 0)
6140 geometry_info.sigma=InterpretLocaleValue(value,
6144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6151 if (LocaleCompare(keyword,"geometry") == 0)
6153 flags=ParseGeometry(value,&geometry_info);
6154 if ((flags & SigmaValue) == 0)
6155 geometry_info.sigma=1.0;
6158 if (LocaleCompare(keyword,"gray") == 0)
6160 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6163 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6165 gray=(MagickBooleanType) option;
6168 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6174 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6180 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6181 geometry_info.sigma,&msl_info->image[n]->exception);
6182 if (shade_image == (Image *) NULL)
6184 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6185 msl_info->image[n]=shade_image;
6188 if (LocaleCompare((const char *) tag,"shadow") == 0)
6196 if (msl_info->image[n] == (Image *) NULL)
6198 ThrowMSLException(OptionError,"NoImagesDefined",
6199 (const char *) tag);
6202 if (attributes != (const xmlChar **) NULL)
6203 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6205 keyword=(const char *) attributes[i++];
6206 attribute=InterpretImageProperties(msl_info->image_info[n],
6207 msl_info->attributes[n],(const char *) attributes[i]);
6208 CloneString(&value,attribute);
6214 if (LocaleCompare(keyword,"geometry") == 0)
6216 flags=ParseGeometry(value,&geometry_info);
6217 if ((flags & SigmaValue) == 0)
6218 geometry_info.sigma=1.0;
6221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6228 if (LocaleCompare(keyword,"opacity") == 0)
6230 geometry_info.rho=StringToLong(value);
6233 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6240 if (LocaleCompare(keyword,"sigma") == 0)
6242 geometry_info.sigma=StringToLong(value);
6250 if (LocaleCompare(keyword,"x") == 0)
6252 geometry_info.xi=InterpretLocaleValue(value,
6256 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6263 if (LocaleCompare(keyword,"y") == 0)
6265 geometry_info.psi=StringToLong(value);
6268 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6274 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6280 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6281 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6282 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6283 if (shadow_image == (Image *) NULL)
6285 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6286 msl_info->image[n]=shadow_image;
6289 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6291 double radius = 0.0,
6294 if (msl_info->image[n] == (Image *) NULL)
6296 ThrowMSLException(OptionError,"NoImagesDefined",
6297 (const char *) tag);
6301 NOTE: sharpen can have no attributes, since we use all the defaults!
6303 if (attributes != (const xmlChar **) NULL)
6305 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6307 keyword=(const char *) attributes[i++];
6308 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6309 msl_info->attributes[n],(const char *) attributes[i]));
6315 if (LocaleCompare(keyword, "radius") == 0)
6317 radius = InterpretLocaleValue(value,(char **) NULL);
6320 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6326 if (LocaleCompare(keyword,"sigma") == 0)
6328 sigma = StringToLong( value );
6331 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6336 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6350 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6351 if (newImage == (Image *) NULL)
6353 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6354 msl_info->image[n]=newImage;
6358 else if (LocaleCompare((const char *) tag,"shave") == 0)
6360 /* init the values */
6364 if (msl_info->image[n] == (Image *) NULL)
6366 ThrowMSLException(OptionError,"NoImagesDefined",
6367 (const char *) tag);
6370 if (attributes == (const xmlChar **) NULL)
6372 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6374 keyword=(const char *) attributes[i++];
6375 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6376 msl_info->attributes[n],(const char *) attributes[i]));
6382 if (LocaleCompare(keyword,"geometry") == 0)
6384 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6387 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6393 if (LocaleCompare(keyword,"height") == 0)
6395 height = StringToLong( value );
6398 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6404 if (LocaleCompare(keyword,"width") == 0)
6406 width = StringToLong( value );
6409 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6414 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6429 rectInfo.height = height;
6430 rectInfo.width = width;
6435 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6436 &msl_info->image[n]->exception);
6437 if (newImage == (Image *) NULL)
6439 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6440 msl_info->image[n]=newImage;
6445 if (LocaleCompare((const char *) tag,"shear") == 0)
6453 if (msl_info->image[n] == (Image *) NULL)
6455 ThrowMSLException(OptionError,"NoImagesDefined",
6456 (const char *) tag);
6459 if (attributes != (const xmlChar **) NULL)
6460 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6462 keyword=(const char *) attributes[i++];
6463 attribute=InterpretImageProperties(msl_info->image_info[n],
6464 msl_info->attributes[n],(const char *) attributes[i]);
6465 CloneString(&value,attribute);
6471 if (LocaleCompare(keyword, "fill") == 0)
6473 (void) QueryColorDatabase(value,
6474 &msl_info->image[n]->background_color,&exception);
6477 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6484 if (LocaleCompare(keyword,"geometry") == 0)
6486 flags=ParseGeometry(value,&geometry_info);
6487 if ((flags & SigmaValue) == 0)
6488 geometry_info.sigma=1.0;
6491 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6498 if (LocaleCompare(keyword,"x") == 0)
6500 geometry_info.rho=InterpretLocaleValue(value,
6504 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6511 if (LocaleCompare(keyword,"y") == 0)
6513 geometry_info.sigma=StringToLong(value);
6516 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6522 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6528 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6529 geometry_info.sigma,&msl_info->image[n]->exception);
6530 if (shear_image == (Image *) NULL)
6532 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6533 msl_info->image[n]=shear_image;
6536 if (LocaleCompare((const char *) tag,"signature") == 0)
6541 if (msl_info->image[n] == (Image *) NULL)
6543 ThrowMSLException(OptionError,"NoImagesDefined",
6544 (const char *) tag);
6547 if (attributes != (const xmlChar **) NULL)
6548 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6550 keyword=(const char *) attributes[i++];
6551 attribute=InterpretImageProperties(msl_info->image_info[n],
6552 msl_info->attributes[n],(const char *) attributes[i]);
6553 CloneString(&value,attribute);
6558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6564 (void) SignatureImage(msl_info->image[n]);
6567 if (LocaleCompare((const char *) tag,"solarize") == 0)
6572 if (msl_info->image[n] == (Image *) NULL)
6574 ThrowMSLException(OptionError,"NoImagesDefined",
6575 (const char *) tag);
6578 geometry_info.rho=QuantumRange/2.0;
6579 if (attributes != (const xmlChar **) NULL)
6580 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6582 keyword=(const char *) attributes[i++];
6583 attribute=InterpretImageProperties(msl_info->image_info[n],
6584 msl_info->attributes[n],(const char *) attributes[i]);
6585 CloneString(&value,attribute);
6591 if (LocaleCompare(keyword,"geometry") == 0)
6593 flags=ParseGeometry(value,&geometry_info);
6596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6603 if (LocaleCompare(keyword,"threshold") == 0)
6605 geometry_info.rho=InterpretLocaleValue(value,
6609 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6615 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6621 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6624 if (LocaleCompare((const char *) tag,"spread") == 0)
6632 if (msl_info->image[n] == (Image *) NULL)
6634 ThrowMSLException(OptionError,"NoImagesDefined",
6635 (const char *) tag);
6638 if (attributes != (const xmlChar **) NULL)
6639 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6641 keyword=(const char *) attributes[i++];
6642 attribute=InterpretImageProperties(msl_info->image_info[n],
6643 msl_info->attributes[n],(const char *) attributes[i]);
6644 CloneString(&value,attribute);
6650 if (LocaleCompare(keyword,"geometry") == 0)
6652 flags=ParseGeometry(value,&geometry_info);
6653 if ((flags & SigmaValue) == 0)
6654 geometry_info.sigma=1.0;
6657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6664 if (LocaleCompare(keyword,"radius") == 0)
6666 geometry_info.rho=InterpretLocaleValue(value,
6670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6682 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6683 &msl_info->image[n]->exception);
6684 if (spread_image == (Image *) NULL)
6686 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6687 msl_info->image[n]=spread_image;
6690 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6693 watermark = (Image*)NULL;
6695 if (msl_info->image[n] == (Image *) NULL)
6697 ThrowMSLException(OptionError,"NoImagesDefined",
6698 (const char *) tag);
6701 if (attributes == (const xmlChar **) NULL)
6703 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6705 keyword=(const char *) attributes[i++];
6706 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6707 msl_info->attributes[n],(const char *) attributes[i]));
6713 if (LocaleCompare(keyword,"image") == 0)
6715 for (j=0; j<msl_info->n;j++)
6718 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6719 if (theAttr && LocaleCompare(theAttr, value) == 0)
6721 watermark = msl_info->image[j];
6727 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6732 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6741 if ( watermark != (Image*) NULL )
6746 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6747 if (newImage == (Image *) NULL)
6749 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6750 msl_info->image[n]=newImage;
6753 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6755 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6758 stereoImage = (Image*)NULL;
6760 if (msl_info->image[n] == (Image *) NULL)
6762 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6765 if (attributes == (const xmlChar **) NULL)
6767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6769 keyword=(const char *) attributes[i++];
6770 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6771 msl_info->attributes[n],(const char *) attributes[i]));
6777 if (LocaleCompare(keyword,"image") == 0)
6779 for (j=0; j<msl_info->n;j++)
6782 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6783 if (theAttr && LocaleCompare(theAttr, value) == 0)
6785 stereoImage = msl_info->image[j];
6791 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6796 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6805 if ( stereoImage != (Image*) NULL )
6810 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6811 if (newImage == (Image *) NULL)
6813 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6814 msl_info->image[n]=newImage;
6817 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6819 if (LocaleCompare((const char *) tag,"swap") == 0)
6830 if (msl_info->image[n] == (Image *) NULL)
6832 ThrowMSLException(OptionError,"NoImagesDefined",
6833 (const char *) tag);
6838 if (attributes != (const xmlChar **) NULL)
6839 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6841 keyword=(const char *) attributes[i++];
6842 attribute=InterpretImageProperties(msl_info->image_info[n],
6843 msl_info->attributes[n],(const char *) attributes[i]);
6844 CloneString(&value,attribute);
6850 if (LocaleCompare(keyword,"indexes") == 0)
6852 flags=ParseGeometry(value,&geometry_info);
6853 index=(ssize_t) geometry_info.rho;
6854 if ((flags & SigmaValue) == 0)
6855 swap_index=(ssize_t) geometry_info.sigma;
6858 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6873 p=GetImageFromList(msl_info->image[n],index);
6874 q=GetImageFromList(msl_info->image[n],swap_index);
6875 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6877 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6880 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6881 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6882 ReplaceImageInList(&q,swap);
6883 msl_info->image[n]=GetFirstImageInList(q);
6886 if (LocaleCompare((const char *) tag,"swirl") == 0)
6894 if (msl_info->image[n] == (Image *) NULL)
6896 ThrowMSLException(OptionError,"NoImagesDefined",
6897 (const char *) tag);
6900 if (attributes != (const xmlChar **) NULL)
6901 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6903 keyword=(const char *) attributes[i++];
6904 attribute=InterpretImageProperties(msl_info->image_info[n],
6905 msl_info->attributes[n],(const char *) attributes[i]);
6906 CloneString(&value,attribute);
6912 if (LocaleCompare(keyword,"degrees") == 0)
6914 geometry_info.rho=InterpretLocaleValue(value,
6918 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6925 if (LocaleCompare(keyword,"geometry") == 0)
6927 flags=ParseGeometry(value,&geometry_info);
6928 if ((flags & SigmaValue) == 0)
6929 geometry_info.sigma=1.0;
6932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6944 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6945 &msl_info->image[n]->exception);
6946 if (swirl_image == (Image *) NULL)
6948 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6949 msl_info->image[n]=swirl_image;
6952 if (LocaleCompare((const char *) tag,"sync") == 0)
6957 if (msl_info->image[n] == (Image *) NULL)
6959 ThrowMSLException(OptionError,"NoImagesDefined",
6960 (const char *) tag);
6963 if (attributes != (const xmlChar **) NULL)
6964 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6966 keyword=(const char *) attributes[i++];
6967 attribute=InterpretImageProperties(msl_info->image_info[n],
6968 msl_info->attributes[n],(const char *) attributes[i]);
6969 CloneString(&value,attribute);
6974 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6980 (void) SyncImage(msl_info->image[n]);
6983 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6988 if (LocaleCompare((const char *) tag,"map") == 0)
6996 if (msl_info->image[n] == (Image *) NULL)
6998 ThrowMSLException(OptionError,"NoImagesDefined",
6999 (const char *) tag);
7002 texture_image=NewImageList();
7003 if (attributes != (const xmlChar **) NULL)
7004 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7006 keyword=(const char *) attributes[i++];
7007 attribute=InterpretImageProperties(msl_info->image_info[n],
7008 msl_info->attributes[n],(const char *) attributes[i]);
7009 CloneString(&value,attribute);
7015 if (LocaleCompare(keyword,"image") == 0)
7016 for (j=0; j < msl_info->n; j++)
7021 attribute=GetImageProperty(msl_info->attributes[j],"id");
7022 if ((attribute != (const char *) NULL) &&
7023 (LocaleCompare(attribute,value) == 0))
7025 texture_image=CloneImage(msl_info->image[j],0,0,
7026 MagickFalse,&exception);
7034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7040 (void) TextureImage(msl_info->image[n],texture_image);
7041 texture_image=DestroyImage(texture_image);
7044 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7046 /* init the values */
7047 double threshold = 0;
7049 if (msl_info->image[n] == (Image *) NULL)
7051 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7054 if (attributes == (const xmlChar **) NULL)
7056 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7058 keyword=(const char *) attributes[i++];
7059 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7060 msl_info->attributes[n],(const char *) attributes[i]));
7066 if (LocaleCompare(keyword,"threshold") == 0)
7068 threshold = InterpretLocaleValue(value,(char **) NULL);
7071 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7076 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7086 BilevelImage(msl_info->image[n],threshold);
7090 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7092 if (msl_info->image[n] == (Image *) NULL)
7094 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7097 if (attributes == (const xmlChar **) NULL)
7099 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7101 keyword=(const char *) attributes[i++];
7102 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7103 msl_info->attributes[n],(const char *) attributes[i]));
7109 if (LocaleCompare(keyword,"color") == 0)
7114 (void) QueryMagickColor(value,&target,&exception);
7115 (void) TransparentPaintImage(msl_info->image[n],&target,
7116 TransparentAlpha,MagickFalse,&msl_info->image[n]->exception);
7119 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7124 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7131 else if (LocaleCompare((const char *) tag, "trim") == 0)
7133 if (msl_info->image[n] == (Image *) NULL)
7135 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7139 /* no attributes here */
7141 /* process the image */
7148 /* all zeros on a crop == trim edges! */
7149 rectInfo.height = rectInfo.width = 0;
7150 rectInfo.x = rectInfo.y = 0;
7152 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7153 if (newImage == (Image *) NULL)
7155 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7156 msl_info->image[n]=newImage;
7160 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7165 if (LocaleCompare((const char *) tag,"write") == 0)
7167 if (msl_info->image[n] == (Image *) NULL)
7169 ThrowMSLException(OptionError,"NoImagesDefined",
7170 (const char *) tag);
7173 if (attributes == (const xmlChar **) NULL)
7175 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7177 keyword=(const char *) attributes[i++];
7178 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7179 msl_info->attributes[n],(const char *) attributes[i]));
7185 if (LocaleCompare(keyword,"filename") == 0)
7187 (void) CopyMagickString(msl_info->image[n]->filename,value,
7191 (void) SetMSLAttributes(msl_info,keyword,value);
7195 (void) SetMSLAttributes(msl_info,keyword,value);
7203 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7204 &msl_info->image[n]->exception);
7208 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7212 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7216 if ( value != NULL )
7217 value=DestroyString(value);
7218 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7221 static void MSLEndElement(void *context,const xmlChar *tag)
7230 Called when the end of an element has been detected.
7232 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7234 msl_info=(MSLInfo *) context;
7241 if (LocaleCompare((const char *) tag,"comment") == 0 )
7243 (void) DeleteImageProperty(msl_info->image[n],"comment");
7244 if (msl_info->content == (char *) NULL)
7246 StripString(msl_info->content);
7247 (void) SetImageProperty(msl_info->image[n],"comment",
7256 if (LocaleCompare((const char *) tag, "group") == 0 )
7258 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7260 ssize_t i = (ssize_t)
7261 (msl_info->group_info[msl_info->number_groups-1].numImages);
7264 if (msl_info->image[msl_info->n] != (Image *) NULL)
7265 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7266 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7267 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7271 msl_info->number_groups--;
7278 if (LocaleCompare((const char *) tag, "image") == 0)
7279 MSLPopImage(msl_info);
7285 if (LocaleCompare((const char *) tag,"label") == 0 )
7287 (void) DeleteImageProperty(msl_info->image[n],"label");
7288 if (msl_info->content == (char *) NULL)
7290 StripString(msl_info->content);
7291 (void) SetImageProperty(msl_info->image[n],"label",
7300 if (LocaleCompare((const char *) tag, "msl") == 0 )
7303 This our base element.
7304 at the moment we don't do anything special
7305 but someday we might!
7313 if (msl_info->content != (char *) NULL)
7314 msl_info->content=DestroyString(msl_info->content);
7317 static void MSLCharacters(void *context,const xmlChar *c,int length)
7329 Receiving some characters from the parser.
7331 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7332 " SAX.characters(%s,%d)",c,length);
7333 msl_info=(MSLInfo *) context;
7334 if (msl_info->content != (char *) NULL)
7335 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7336 strlen(msl_info->content)+length+MaxTextExtent,
7337 sizeof(*msl_info->content));
7340 msl_info->content=(char *) NULL;
7341 if (~length >= (MaxTextExtent-1))
7342 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7343 sizeof(*msl_info->content));
7344 if (msl_info->content != (char *) NULL)
7345 *msl_info->content='\0';
7347 if (msl_info->content == (char *) NULL)
7349 p=msl_info->content+strlen(msl_info->content);
7350 for (i=0; i < length; i++)
7355 static void MSLReference(void *context,const xmlChar *name)
7364 Called when an entity reference is detected.
7366 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7367 " SAX.reference(%s)",name);
7368 msl_info=(MSLInfo *) context;
7369 parser=msl_info->parser;
7371 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7373 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7376 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7382 Receiving some ignorable whitespaces from the parser.
7384 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7385 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7386 msl_info=(MSLInfo *) context;
7390 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7391 const xmlChar *data)
7397 A processing instruction has been parsed.
7399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7400 " SAX.processingInstruction(%s, %s)",
7402 msl_info=(MSLInfo *) context;
7406 static void MSLComment(void *context,const xmlChar *value)
7412 A comment has been parsed.
7414 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7415 " SAX.comment(%s)",value);
7416 msl_info=(MSLInfo *) context;
7420 static void MSLWarning(void *context,const char *format,...)
7424 reason[MaxTextExtent];
7433 Display and format a warning messages, gives file, line, position and
7436 va_start(operands,format);
7437 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7438 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7439 msl_info=(MSLInfo *) context;
7441 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7442 (void) vsprintf(reason,format,operands);
7444 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7446 message=GetExceptionMessage(errno);
7447 ThrowMSLException(CoderError,reason,message);
7448 message=DestroyString(message);
7452 static void MSLError(void *context,const char *format,...)
7455 reason[MaxTextExtent];
7464 Display and format a error formats, gives file, line, position and
7467 va_start(operands,format);
7468 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7469 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7470 msl_info=(MSLInfo *) context;
7472 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7473 (void) vsprintf(reason,format,operands);
7475 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7477 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7481 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7493 Called when a pcdata block has been parsed.
7495 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7496 " SAX.pcdata(%s, %d)",value,length);
7497 msl_info=(MSLInfo *) context;
7499 parser=msl_info->parser;
7500 child=xmlGetLastChild(parser->node);
7501 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7503 xmlTextConcat(child,value,length);
7506 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7509 static void MSLExternalSubset(void *context,const xmlChar *name,
7510 const xmlChar *external_id,const xmlChar *system_id)
7525 Does this document has an external subset?
7527 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7528 " SAX.externalSubset(%s %s %s)",name,
7529 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7530 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7531 msl_info=(MSLInfo *) context;
7533 parser=msl_info->parser;
7534 if (((external_id == NULL) && (system_id == NULL)) ||
7535 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7536 (msl_info->document == 0)))
7538 input=MSLResolveEntity(context,external_id,system_id);
7541 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7542 parser_context=(*parser);
7543 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7544 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7546 parser->errNo=XML_ERR_NO_MEMORY;
7547 parser->input=parser_context.input;
7548 parser->inputNr=parser_context.inputNr;
7549 parser->inputMax=parser_context.inputMax;
7550 parser->inputTab=parser_context.inputTab;
7556 xmlPushInput(parser,input);
7557 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7558 if (input->filename == (char *) NULL)
7559 input->filename=(char *) xmlStrdup(system_id);
7562 input->base=parser->input->cur;
7563 input->cur=parser->input->cur;
7565 xmlParseExternalSubset(parser,external_id,system_id);
7566 while (parser->inputNr > 1)
7567 (void) xmlPopInput(parser);
7568 xmlFreeInputStream(parser->input);
7569 xmlFree(parser->inputTab);
7570 parser->input=parser_context.input;
7571 parser->inputNr=parser_context.inputNr;
7572 parser->inputMax=parser_context.inputMax;
7573 parser->inputTab=parser_context.inputTab;
7576 #if defined(__cplusplus) || defined(c_plusplus)
7580 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7581 ExceptionInfo *exception)
7584 message[MaxTextExtent];
7607 assert(image_info != (const ImageInfo *) NULL);
7608 assert(image_info->signature == MagickSignature);
7609 if (image_info->debug != MagickFalse)
7610 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7611 image_info->filename);
7612 assert(image != (Image **) NULL);
7613 msl_image=AcquireImage(image_info);
7614 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7615 if (status == MagickFalse)
7617 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7618 msl_image->filename);
7619 msl_image=DestroyImageList(msl_image);
7620 return(MagickFalse);
7622 msl_image->columns=1;
7627 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7628 msl_info.exception=exception;
7629 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7630 sizeof(*msl_info.image_info));
7631 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7632 sizeof(*msl_info.draw_info));
7633 /* top of the stack is the MSL file itself */
7634 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7635 msl_info.attributes=(Image **) AcquireMagickMemory(
7636 sizeof(*msl_info.attributes));
7637 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7638 sizeof(*msl_info.group_info));
7639 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7640 (msl_info.image == (Image **) NULL) ||
7641 (msl_info.attributes == (Image **) NULL) ||
7642 (msl_info.group_info == (MSLGroupInfo *) NULL))
7643 ThrowFatalException(ResourceLimitFatalError,
7644 "UnableToInterpretMSLImage");
7645 *msl_info.image_info=CloneImageInfo(image_info);
7646 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7647 *msl_info.attributes=AcquireImage(image_info);
7648 msl_info.group_info[0].numImages=0;
7649 /* the first slot is used to point to the MSL file image */
7650 *msl_info.image=msl_image;
7651 if (*image != (Image *) NULL)
7652 MSLPushImage(&msl_info,*image);
7653 (void) xmlSubstituteEntitiesDefault(1);
7654 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7655 sax_modules.internalSubset=MSLInternalSubset;
7656 sax_modules.isStandalone=MSLIsStandalone;
7657 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7658 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7659 sax_modules.resolveEntity=MSLResolveEntity;
7660 sax_modules.getEntity=MSLGetEntity;
7661 sax_modules.entityDecl=MSLEntityDeclaration;
7662 sax_modules.notationDecl=MSLNotationDeclaration;
7663 sax_modules.attributeDecl=MSLAttributeDeclaration;
7664 sax_modules.elementDecl=MSLElementDeclaration;
7665 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7666 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7667 sax_modules.startDocument=MSLStartDocument;
7668 sax_modules.endDocument=MSLEndDocument;
7669 sax_modules.startElement=MSLStartElement;
7670 sax_modules.endElement=MSLEndElement;
7671 sax_modules.reference=MSLReference;
7672 sax_modules.characters=MSLCharacters;
7673 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7674 sax_modules.processingInstruction=MSLProcessingInstructions;
7675 sax_modules.comment=MSLComment;
7676 sax_modules.warning=MSLWarning;
7677 sax_modules.error=MSLError;
7678 sax_modules.fatalError=MSLError;
7679 sax_modules.getParameterEntity=MSLGetParameterEntity;
7680 sax_modules.cdataBlock=MSLCDataBlock;
7681 sax_modules.externalSubset=MSLExternalSubset;
7682 sax_handler=(&sax_modules);
7683 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7684 msl_image->filename);
7685 while (ReadBlobString(msl_image,message) != (char *) NULL)
7687 n=(ssize_t) strlen(message);
7690 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7693 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7694 if (msl_info.exception->severity >= ErrorException)
7697 if (msl_info.exception->severity == UndefinedException)
7698 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7699 xmlFreeParserCtxt(msl_info.parser);
7700 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7702 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7703 msl_info.group_info);
7704 if (*image == (Image *) NULL)
7705 *image=(*msl_info.image);
7706 if ((*msl_info.image)->exception.severity != UndefinedException)
7707 return(MagickFalse);
7711 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7719 assert(image_info != (const ImageInfo *) NULL);
7720 assert(image_info->signature == MagickSignature);
7721 if (image_info->debug != MagickFalse)
7722 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7723 image_info->filename);
7724 assert(exception != (ExceptionInfo *) NULL);
7725 assert(exception->signature == MagickSignature);
7726 image=(Image *) NULL;
7727 (void) ProcessMSLScript(image_info,&image,exception);
7728 return(GetFirstImageInList(image));
7733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7737 % R e g i s t e r M S L I m a g e %
7741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7743 % RegisterMSLImage() adds attributes for the MSL image format to
7744 % the list of supported formats. The attributes include the image format
7745 % tag, a method to read and/or write the format, whether the format
7746 % supports the saving of more than one frame to the same file or blob,
7747 % whether the format supports native in-memory I/O, and a brief
7748 % description of the format.
7750 % The format of the RegisterMSLImage method is:
7752 % size_t RegisterMSLImage(void)
7755 ModuleExport size_t RegisterMSLImage(void)
7760 entry=SetMagickInfo("MSL");
7761 #if defined(MAGICKCORE_XML_DELEGATE)
7762 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7763 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7765 entry->description=ConstantString("Magick Scripting Language");
7766 entry->module=ConstantString("MSL");
7767 (void) RegisterMagickInfo(entry);
7768 return(MagickImageCoderSignature);
7771 #if defined(MAGICKCORE_XML_DELEGATE)
7773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7777 % S e t M S L A t t r i b u t e s %
7781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7783 % SetMSLAttributes() ...
7785 % The format of the SetMSLAttributes method is:
7787 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7788 % const char *keyword,const char *value)
7790 % A description of each parameter follows:
7792 % o msl_info: the MSL info.
7794 % o keyword: the keyword.
7796 % o value: the value.
7799 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7826 assert(msl_info != (MSLInfo *) NULL);
7827 if (keyword == (const char *) NULL)
7829 if (value == (const char *) NULL)
7831 exception=msl_info->exception;
7833 attributes=msl_info->attributes[n];
7834 image_info=msl_info->image_info[n];
7835 draw_info=msl_info->draw_info[n];
7836 image=msl_info->image[n];
7842 if (LocaleCompare(keyword,"adjoin") == 0)
7847 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7849 ThrowMSLException(OptionError,"UnrecognizedType",value);
7850 image_info->adjoin=(MagickBooleanType) adjoin;
7853 if (LocaleCompare(keyword,"alpha") == 0)
7858 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7860 ThrowMSLException(OptionError,"UnrecognizedType",value);
7861 if (image != (Image *) NULL)
7862 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7866 if (LocaleCompare(keyword,"antialias") == 0)
7871 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7873 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7874 image_info->antialias=(MagickBooleanType) antialias;
7877 if (LocaleCompare(keyword,"area-limit") == 0)
7882 limit=MagickResourceInfinity;
7883 if (LocaleCompare(value,"unlimited") != 0)
7884 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7885 (void) SetMagickResourceLimit(AreaResource,limit);
7888 if (LocaleCompare(keyword,"attenuate") == 0)
7890 (void) SetImageOption(image_info,keyword,value);
7893 if (LocaleCompare(keyword,"authenticate") == 0)
7895 (void) CloneString(&image_info->density,value);
7898 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7904 if (LocaleCompare(keyword,"background") == 0)
7906 (void) QueryColorDatabase(value,&image_info->background_color,
7910 if (LocaleCompare(keyword,"bias") == 0)
7912 if (image == (Image *) NULL)
7914 image->bias=SiPrefixToDouble(value,QuantumRange);
7917 if (LocaleCompare(keyword,"blue-primary") == 0)
7919 if (image == (Image *) NULL)
7921 flags=ParseGeometry(value,&geometry_info);
7922 image->chromaticity.blue_primary.x=geometry_info.rho;
7923 image->chromaticity.blue_primary.y=geometry_info.sigma;
7924 if ((flags & SigmaValue) == 0)
7925 image->chromaticity.blue_primary.y=
7926 image->chromaticity.blue_primary.x;
7929 if (LocaleCompare(keyword,"bordercolor") == 0)
7931 (void) QueryColorDatabase(value,&image_info->border_color,
7935 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7941 if (LocaleCompare(keyword,"density") == 0)
7943 (void) CloneString(&image_info->density,value);
7944 (void) CloneString(&draw_info->density,value);
7947 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7953 if (LocaleCompare(keyword,"fill") == 0)
7955 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7956 (void) SetImageOption(image_info,keyword,value);
7959 if (LocaleCompare(keyword,"filename") == 0)
7961 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7964 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7970 if (LocaleCompare(keyword,"gravity") == 0)
7975 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7977 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7978 (void) SetImageOption(image_info,keyword,value);
7981 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7987 if (LocaleCompare(keyword,"id") == 0)
7989 (void) SetImageProperty(attributes,keyword,value);
7992 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7998 if (LocaleCompare(keyword,"magick") == 0)
8000 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8003 if (LocaleCompare(keyword,"mattecolor") == 0)
8005 (void) QueryColorDatabase(value,&image_info->matte_color,
8009 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8015 if (LocaleCompare(keyword,"pointsize") == 0)
8017 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8018 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8021 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8027 if (LocaleCompare(keyword,"quality") == 0)
8029 image_info->quality=StringToLong(value);
8030 if (image == (Image *) NULL)
8032 image->quality=StringToLong(value);
8040 if (LocaleCompare(keyword,"size") == 0)
8042 (void) CloneString(&image_info->size,value);
8045 if (LocaleCompare(keyword,"stroke") == 0)
8047 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8048 (void) SetImageOption(image_info,keyword,value);
8051 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8056 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8069 % U n r e g i s t e r M S L I m a g e %
8073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8075 % UnregisterMSLImage() removes format registrations made by the
8076 % MSL module from the list of supported formats.
8078 % The format of the UnregisterMSLImage method is:
8080 % UnregisterMSLImage(void)
8083 ModuleExport void UnregisterMSLImage(void)
8085 (void) UnregisterMagickInfo("MSL");
8088 #if defined(MAGICKCORE_XML_DELEGATE)
8090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8094 % W r i t e M S L I m a g e %
8098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8100 % WriteMSLImage() writes an image to a file in MVG image format.
8102 % The format of the WriteMSLImage method is:
8104 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8105 % Image *image,ExceptionInfo *exception)
8107 % A description of each parameter follows.
8109 % o image_info: the image info.
8111 % o image: The image.
8113 % o exception: return any errors or warnings in this structure.
8116 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8117 ExceptionInfo *exception)
8119 assert(image_info != (const ImageInfo *) NULL);
8120 assert(image_info->signature == MagickSignature);
8121 assert(image != (Image *) NULL);
8122 assert(image->signature == MagickSignature);
8123 if (image->debug != MagickFalse)
8124 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8125 (void) ReferenceImage(image);
8126 (void) ProcessMSLScript(image_info,&image,exception);