2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2012 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/color-private.h"
53 #include "MagickCore/colormap.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/distort.h"
59 #include "MagickCore/draw.h"
60 #include "MagickCore/effect.h"
61 #include "MagickCore/enhance.h"
62 #include "MagickCore/exception.h"
63 #include "MagickCore/exception-private.h"
64 #include "MagickCore/fx.h"
65 #include "MagickCore/geometry.h"
66 #include "MagickCore/image.h"
67 #include "MagickCore/image-private.h"
68 #include "MagickCore/list.h"
69 #include "MagickCore/log.h"
70 #include "MagickCore/magick.h"
71 #include "MagickCore/memory_.h"
72 #include "MagickCore/module.h"
73 #include "MagickCore/option.h"
74 #include "MagickCore/paint.h"
75 #include "MagickCore/pixel-accessor.h"
76 #include "MagickCore/profile.h"
77 #include "MagickCore/property.h"
78 #include "MagickCore/quantize.h"
79 #include "MagickCore/quantum-private.h"
80 #include "MagickCore/registry.h"
81 #include "MagickCore/resize.h"
82 #include "MagickCore/resource_.h"
83 #include "MagickCore/segment.h"
84 #include "MagickCore/shear.h"
85 #include "MagickCore/signature.h"
86 #include "MagickCore/statistic.h"
87 #include "MagickCore/static.h"
88 #include "MagickCore/string_.h"
89 #include "MagickCore/string-private.h"
90 #include "MagickCore/transform.h"
91 #include "MagickCore/threshold.h"
92 #include "MagickCore/utility.h"
93 #if defined(MAGICKCORE_XML_DELEGATE)
94 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
95 # if defined(__MINGW32__)
98 # include <win32config.h>
101 # include <libxml/parser.h>
102 # include <libxml/xmlmemory.h>
103 # include <libxml/parserInternals.h>
104 # include <libxml/xmlerror.h>
110 #define ThrowMSLException(severity,tag,reason) \
111 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
115 Typedef declaractions.
117 typedef struct _MSLGroupInfo
120 numImages; /* how many images are in this group */
123 typedef struct _MSLInfo
148 #if defined(MAGICKCORE_XML_DELEGATE)
158 Forward declarations.
160 #if defined(MAGICKCORE_XML_DELEGATE)
161 static MagickBooleanType
162 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
164 static MagickBooleanType
165 SetMSLAttributes(MSLInfo *,const char *,const char *);
168 #if defined(MAGICKCORE_XML_DELEGATE)
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 % R e a d M S L I m a g e %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
182 % It allocates the memory necessary for the new Image structure and returns a
183 % pointer to the new image.
185 % The format of the ReadMSLImage method is:
187 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
189 % A description of each parameter follows:
191 % o image_info: the image info.
193 % o exception: return any errors or warnings in this structure.
197 #if defined(__cplusplus) || defined(c_plusplus)
201 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
202 ExceptionInfo *exception)
216 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
217 sans_exception=AcquireExceptionInfo();
218 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
219 sans_exception=DestroyExceptionInfo(sans_exception);
220 if (image != (Image *) NULL)
222 read_info=CloneImageInfo(image_info);
223 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
224 image=ReadImage(read_info,exception);
225 read_info=DestroyImageInfo(read_info);
226 if (image != (Image *) NULL)
227 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
231 static int IsPathDirectory(const char *path)
239 if ((path == (const char *) NULL) || (*path == '\0'))
241 status=GetPathAttributes(path,&attributes);
242 if (status == MagickFalse)
244 if (S_ISDIR(attributes.st_mode) == 0)
249 static int MSLIsStandalone(void *context)
255 Is this document tagged standalone?
257 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
258 msl_info=(MSLInfo *) context;
259 return(msl_info->document->standalone == 1);
262 static int MSLHasInternalSubset(void *context)
268 Does this document has an internal subset?
270 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
271 " SAX.MSLHasInternalSubset()");
272 msl_info=(MSLInfo *) context;
273 return(msl_info->document->intSubset != NULL);
276 static int MSLHasExternalSubset(void *context)
282 Does this document has an external subset?
284 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
285 " SAX.MSLHasExternalSubset()");
286 msl_info=(MSLInfo *) context;
287 return(msl_info->document->extSubset != NULL);
290 static void MSLInternalSubset(void *context,const xmlChar *name,
291 const xmlChar *external_id,const xmlChar *system_id)
297 Does this document has an internal subset?
299 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
300 " SAX.internalSubset(%s %s %s)",name,
301 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
302 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
303 msl_info=(MSLInfo *) context;
304 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
307 static xmlParserInputPtr MSLResolveEntity(void *context,
308 const xmlChar *public_id,const xmlChar *system_id)
317 Special entity resolver, better left to the parser, it has more
318 context than the application layer. The default behaviour is to
319 not resolve the entities, in that case the ENTITY_REF nodes are
320 built in the structure (and the parameter values).
322 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
323 " SAX.resolveEntity(%s, %s)",
324 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
325 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
326 msl_info=(MSLInfo *) context;
327 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
328 public_id,msl_info->parser);
332 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
338 Get an entity by name.
340 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
341 " SAX.MSLGetEntity(%s)",(const char *) name);
342 msl_info=(MSLInfo *) context;
343 return(xmlGetDocEntity(msl_info->document,name));
346 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
352 Get a parameter entity by name.
354 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
355 " SAX.getParameterEntity(%s)",(const char *) name);
356 msl_info=(MSLInfo *) context;
357 return(xmlGetParameterEntity(msl_info->document,name));
360 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
361 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
367 An entity definition has been parsed.
369 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
370 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
371 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
372 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
374 msl_info=(MSLInfo *) context;
375 if (msl_info->parser->inSubset == 1)
376 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
379 if (msl_info->parser->inSubset == 2)
380 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
384 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
385 const xmlChar *name,int type,int value,const xmlChar *default_value,
386 xmlEnumerationPtr tree)
399 An attribute definition has been parsed.
401 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
402 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
404 msl_info=(MSLInfo *) context;
405 fullname=(xmlChar *) NULL;
406 prefix=(xmlChar *) NULL;
407 parser=msl_info->parser;
408 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
409 if (parser->inSubset == 1)
410 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
411 element,fullname,prefix,(xmlAttributeType) type,
412 (xmlAttributeDefault) value,default_value,tree);
414 if (parser->inSubset == 2)
415 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
416 element,fullname,prefix,(xmlAttributeType) type,
417 (xmlAttributeDefault) value,default_value,tree);
418 if (prefix != (xmlChar *) NULL)
420 if (fullname != (xmlChar *) NULL)
424 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
425 xmlElementContentPtr content)
434 An element definition has been parsed.
436 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
437 " SAX.elementDecl(%s, %d, ...)",name,type);
438 msl_info=(MSLInfo *) context;
439 parser=msl_info->parser;
440 if (parser->inSubset == 1)
441 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
442 name,(xmlElementTypeVal) type,content);
444 if (parser->inSubset == 2)
445 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
446 name,(xmlElementTypeVal) type,content);
449 static void MSLNotationDeclaration(void *context,const xmlChar *name,
450 const xmlChar *public_id,const xmlChar *system_id)
459 What to do when a notation declaration has been parsed.
461 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
462 " SAX.notationDecl(%s, %s, %s)",name,
463 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
464 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
465 msl_info=(MSLInfo *) context;
466 parser=msl_info->parser;
467 if (parser->inSubset == 1)
468 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
469 name,public_id,system_id);
471 if (parser->inSubset == 2)
472 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
473 name,public_id,system_id);
476 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
477 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
483 What to do when an unparsed entity declaration is parsed.
485 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
486 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
487 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
488 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
490 msl_info=(MSLInfo *) context;
491 (void) xmlAddDocEntity(msl_info->document,name,
492 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
496 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
502 Receive the document locator at startup, actually xmlDefaultSAXLocator.
504 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
505 " SAX.setDocumentLocator()\n");
507 msl_info=(MSLInfo *) context;
511 static void MSLStartDocument(void *context)
520 Called when the document start being processed.
522 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
523 " SAX.startDocument()");
524 msl_info=(MSLInfo *) context;
525 parser=msl_info->parser;
526 msl_info->document=xmlNewDoc(parser->version);
527 if (msl_info->document == (xmlDocPtr) NULL)
529 if (parser->encoding == NULL)
530 msl_info->document->encoding=NULL;
532 msl_info->document->encoding=xmlStrdup(parser->encoding);
533 msl_info->document->standalone=parser->standalone;
536 static void MSLEndDocument(void *context)
542 Called when the document end has been detected.
544 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
545 msl_info=(MSLInfo *) context;
546 if (msl_info->content != (char *) NULL)
547 msl_info->content=DestroyString(msl_info->content);
550 static void MSLPushImage(MSLInfo *msl_info,Image *image)
555 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
556 assert(msl_info != (MSLInfo *) NULL);
559 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
560 (n+1),sizeof(*msl_info->image_info));
561 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
562 (n+1),sizeof(*msl_info->draw_info));
563 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
564 (n+1),sizeof(*msl_info->attributes));
565 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
566 sizeof(*msl_info->image));
567 if ((msl_info->image_info == (ImageInfo **) NULL) ||
568 (msl_info->draw_info == (DrawInfo **) NULL) ||
569 (msl_info->attributes == (Image **) NULL) ||
570 (msl_info->image == (Image **) NULL))
571 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
572 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
573 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
574 msl_info->draw_info[n-1]);
575 if (image == (Image *) NULL)
576 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n],
577 msl_info->exception);
579 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,
580 msl_info->exception);
581 msl_info->image[n]=(Image *) image;
582 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
583 (msl_info->attributes[n] == (Image *) NULL))
584 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
585 if (msl_info->number_groups != 0)
586 msl_info->group_info[msl_info->number_groups-1].numImages++;
589 static void MSLPopImage(MSLInfo *msl_info)
591 if (msl_info->number_groups != 0)
593 if (msl_info->image[msl_info->n] != (Image *) NULL)
594 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
595 msl_info->attributes[msl_info->n]=DestroyImage(
596 msl_info->attributes[msl_info->n]);
597 msl_info->image_info[msl_info->n]=DestroyImageInfo(
598 msl_info->image_info[msl_info->n]);
602 static void MSLStartElement(void *context,const xmlChar *tag,
603 const xmlChar **attributes)
662 Called when an opening tag has been processed.
664 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
665 " SAX.startElement(%s",tag);
666 GetExceptionInfo(&exception);
667 msl_info=(MSLInfo *) context;
669 keyword=(const char *) NULL;
671 SetGeometryInfo(&geometry_info);
672 channel=DefaultChannels;
678 if (LocaleCompare((const char *) tag,"add-noise") == 0)
689 if (msl_info->image[n] == (Image *) NULL)
691 ThrowMSLException(OptionError,"NoImagesDefined",
696 if (attributes != (const xmlChar **) NULL)
697 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
699 keyword=(const char *) attributes[i++];
700 attribute=InterpretImageProperties(msl_info->image_info[n],
701 msl_info->attributes[n],(const char *) attributes[i],
703 CloneString(&value,attribute);
709 if (LocaleCompare(keyword,"channel") == 0)
711 option=ParseChannelOption(value);
713 ThrowMSLException(OptionError,"UnrecognizedChannelType",
715 channel=(ChannelType) option;
718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
725 if (LocaleCompare(keyword,"noise") == 0)
727 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
730 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
732 noise=(NoiseType) option;
735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
747 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
748 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
749 msl_info->exception);
750 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
751 if (noise_image == (Image *) NULL)
753 msl_info->image[n]=DestroyImage(msl_info->image[n]);
754 msl_info->image[n]=noise_image;
757 if (LocaleCompare((const char *) tag,"annotate") == 0)
765 if (msl_info->image[n] == (Image *) NULL)
767 ThrowMSLException(OptionError,"NoImagesDefined",
771 draw_info=CloneDrawInfo(msl_info->image_info[n],
772 msl_info->draw_info[n]);
774 current=draw_info->affine;
775 GetAffineMatrix(&affine);
776 if (attributes != (const xmlChar **) NULL)
777 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
779 keyword=(const char *) attributes[i++];
780 attribute=InterpretImageProperties(msl_info->image_info[n],
781 msl_info->attributes[n],(const char *) attributes[i],
783 CloneString(&value,attribute);
789 if (LocaleCompare(keyword,"affine") == 0)
795 draw_info->affine.sx=StringToDouble(p,&p);
798 draw_info->affine.rx=StringToDouble(p,&p);
801 draw_info->affine.ry=StringToDouble(p,&p);
804 draw_info->affine.sy=StringToDouble(p,&p);
807 draw_info->affine.tx=StringToDouble(p,&p);
810 draw_info->affine.ty=StringToDouble(p,&p);
813 if (LocaleCompare(keyword,"align") == 0)
815 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
818 ThrowMSLException(OptionError,"UnrecognizedAlignType",
820 draw_info->align=(AlignType) option;
823 if (LocaleCompare(keyword,"antialias") == 0)
825 option=ParseCommandOption(MagickBooleanOptions,
828 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
830 draw_info->stroke_antialias=(MagickBooleanType) option;
831 draw_info->text_antialias=(MagickBooleanType) option;
834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
841 if (LocaleCompare(keyword,"density") == 0)
843 CloneString(&draw_info->density,value);
846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
853 if (LocaleCompare(keyword,"encoding") == 0)
855 CloneString(&draw_info->encoding,value);
858 ThrowMSLException(OptionError,"UnrecognizedAttribute",
865 if (LocaleCompare(keyword, "fill") == 0)
867 (void) QueryColorCompliance(value,AllCompliance,
868 &draw_info->fill,&exception);
871 if (LocaleCompare(keyword,"family") == 0)
873 CloneString(&draw_info->family,value);
876 if (LocaleCompare(keyword,"font") == 0)
878 CloneString(&draw_info->font,value);
881 ThrowMSLException(OptionError,"UnrecognizedAttribute",
888 if (LocaleCompare(keyword,"geometry") == 0)
890 flags=ParseGravityGeometry(msl_info->image[n],value,
891 &geometry,&exception);
894 if (LocaleCompare(keyword,"gravity") == 0)
896 option=ParseCommandOption(MagickGravityOptions,
899 ThrowMSLException(OptionError,"UnrecognizedGravityType",
901 draw_info->gravity=(GravityType) option;
904 ThrowMSLException(OptionError,"UnrecognizedAttribute",
911 if (LocaleCompare(keyword,"pointsize") == 0)
913 draw_info->pointsize=StringToDouble(value,(char **) NULL);
916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
923 if (LocaleCompare(keyword,"rotate") == 0)
925 angle=StringToDouble(value,(char **) NULL);
926 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
927 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
928 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
929 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
939 if (LocaleCompare(keyword,"scale") == 0)
941 flags=ParseGeometry(value,&geometry_info);
942 if ((flags & SigmaValue) == 0)
943 geometry_info.sigma=1.0;
944 affine.sx=geometry_info.rho;
945 affine.sy=geometry_info.sigma;
948 if (LocaleCompare(keyword,"skewX") == 0)
950 angle=StringToDouble(value,(char **) NULL);
951 affine.ry=tan(DegreesToRadians(fmod((double) angle,
955 if (LocaleCompare(keyword,"skewY") == 0)
957 angle=StringToDouble(value,(char **) NULL);
958 affine.rx=tan(DegreesToRadians(fmod((double) angle,
962 if (LocaleCompare(keyword,"stretch") == 0)
964 option=ParseCommandOption(MagickStretchOptions,
967 ThrowMSLException(OptionError,"UnrecognizedStretchType",
969 draw_info->stretch=(StretchType) option;
972 if (LocaleCompare(keyword, "stroke") == 0)
974 (void) QueryColorCompliance(value,AllCompliance,
975 &draw_info->stroke,&exception);
978 if (LocaleCompare(keyword,"strokewidth") == 0)
980 draw_info->stroke_width=StringToLong(value);
983 if (LocaleCompare(keyword,"style") == 0)
985 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
988 ThrowMSLException(OptionError,"UnrecognizedStyleType",
990 draw_info->style=(StyleType) option;
993 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1000 if (LocaleCompare(keyword,"text") == 0)
1002 CloneString(&draw_info->text,value);
1005 if (LocaleCompare(keyword,"translate") == 0)
1007 flags=ParseGeometry(value,&geometry_info);
1008 if ((flags & SigmaValue) == 0)
1009 geometry_info.sigma=1.0;
1010 affine.tx=geometry_info.rho;
1011 affine.ty=geometry_info.sigma;
1014 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1021 if (LocaleCompare(keyword, "undercolor") == 0)
1023 (void) QueryColorCompliance(value,AllCompliance,
1024 &draw_info->undercolor,&exception);
1027 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1034 if (LocaleCompare(keyword,"weight") == 0)
1036 draw_info->weight=StringToLong(value);
1039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1046 if (LocaleCompare(keyword,"x") == 0)
1048 geometry.x=StringToLong(value);
1051 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1058 if (LocaleCompare(keyword,"y") == 0)
1060 geometry.y=StringToLong(value);
1063 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1069 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1075 (void) FormatLocaleString(text,MaxTextExtent,
1076 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1077 geometry.height,(double) geometry.x,(double) geometry.y);
1078 CloneString(&draw_info->geometry,text);
1079 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1080 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1081 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1082 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1083 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1085 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1087 (void) AnnotateImage(msl_info->image[n],draw_info,
1088 msl_info->exception);
1089 draw_info=DestroyDrawInfo(draw_info);
1092 if (LocaleCompare((const char *) tag,"append") == 0)
1100 if (msl_info->image[n] == (Image *) NULL)
1102 ThrowMSLException(OptionError,"NoImagesDefined",
1103 (const char *) tag);
1107 if (attributes != (const xmlChar **) NULL)
1108 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1110 keyword=(const char *) attributes[i++];
1111 attribute=InterpretImageProperties(msl_info->image_info[n],
1112 msl_info->attributes[n],(const char *) attributes[i],
1114 CloneString(&value,attribute);
1120 if (LocaleCompare(keyword,"stack") == 0)
1122 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1125 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1127 stack=(MagickBooleanType) option;
1130 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1136 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1142 append_image=AppendImages(msl_info->image[n],stack,
1143 msl_info->exception);
1144 if (append_image == (Image *) NULL)
1146 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1147 msl_info->image[n]=append_image;
1150 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1156 if (LocaleCompare((const char *) tag,"blur") == 0)
1164 if (msl_info->image[n] == (Image *) NULL)
1166 ThrowMSLException(OptionError,"NoImagesDefined",
1167 (const char *) tag);
1170 if (attributes != (const xmlChar **) NULL)
1171 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1173 keyword=(const char *) attributes[i++];
1174 attribute=InterpretImageProperties(msl_info->image_info[n],
1175 msl_info->attributes[n],(const char *) attributes[i],
1177 CloneString(&value,attribute);
1183 if (LocaleCompare(keyword,"channel") == 0)
1185 option=ParseChannelOption(value);
1187 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1189 channel=(ChannelType) option;
1192 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1199 if (LocaleCompare(keyword,"geometry") == 0)
1201 flags=ParseGeometry(value,&geometry_info);
1202 if ((flags & SigmaValue) == 0)
1203 geometry_info.sigma=1.0;
1206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1213 if (LocaleCompare(keyword,"radius") == 0)
1215 geometry_info.rho=StringToDouble(value,(char **) NULL);
1218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1225 if (LocaleCompare(keyword,"sigma") == 0)
1227 geometry_info.sigma=StringToLong(value);
1230 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1236 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1242 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1243 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1244 geometry_info.sigma,geometry_info.xi,
1245 msl_info->exception);
1246 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
1247 if (blur_image == (Image *) NULL)
1249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1250 msl_info->image[n]=blur_image;
1253 if (LocaleCompare((const char *) tag,"border") == 0)
1261 if (msl_info->image[n] == (Image *) NULL)
1263 ThrowMSLException(OptionError,"NoImagesDefined",
1264 (const char *) tag);
1267 SetGeometry(msl_info->image[n],&geometry);
1268 if (attributes != (const xmlChar **) NULL)
1269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1271 keyword=(const char *) attributes[i++];
1272 attribute=InterpretImageProperties(msl_info->image_info[n],
1273 msl_info->attributes[n],(const char *) attributes[i],
1275 CloneString(&value,attribute);
1281 if (LocaleCompare(keyword,"compose") == 0)
1283 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1286 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1288 msl_info->image[n]->compose=(CompositeOperator) option;
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword, "fill") == 0)
1300 (void) QueryColorCompliance(value,AllCompliance,
1301 &msl_info->image[n]->border_color,&exception);
1304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1311 if (LocaleCompare(keyword,"geometry") == 0)
1313 flags=ParsePageGeometry(msl_info->image[n],value,
1314 &geometry,&exception);
1315 if ((flags & HeightValue) == 0)
1316 geometry.height=geometry.width;
1319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1326 if (LocaleCompare(keyword,"height") == 0)
1328 geometry.height=StringToLong(value);
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 if (LocaleCompare(keyword,"width") == 0)
1340 geometry.width=StringToLong(value);
1343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1355 border_image=BorderImage(msl_info->image[n],&geometry,
1356 msl_info->image[n]->compose,msl_info->exception);
1357 if (border_image == (Image *) NULL)
1359 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1360 msl_info->image[n]=border_image;
1363 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1368 if (LocaleCompare((const char *) tag,"colorize") == 0)
1371 blend[MaxTextExtent];
1382 if (msl_info->image[n] == (Image *) NULL)
1384 ThrowMSLException(OptionError,"NoImagesDefined",
1385 (const char *) tag);
1388 GetPixelInfo(msl_info->image[n],&target);
1389 (void) CopyMagickString(blend,"100",MaxTextExtent);
1390 if (attributes != (const xmlChar **) NULL)
1391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1393 keyword=(const char *) attributes[i++];
1394 attribute=InterpretImageProperties(msl_info->image_info[n],
1395 msl_info->attributes[n],(const char *) attributes[i],
1397 CloneString(&value,attribute);
1403 if (LocaleCompare(keyword,"blend") == 0)
1405 (void) CopyMagickString(blend,value,MaxTextExtent);
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 if (LocaleCompare(keyword,"fill") == 0)
1417 (void) QueryColorCompliance(value,AllCompliance,
1418 &target,msl_info->exception);
1421 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1433 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1434 msl_info->exception);
1435 if (colorize_image == (Image *) NULL)
1437 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1438 msl_info->image[n]=colorize_image;
1441 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1447 if (msl_info->image[n] == (Image *) NULL)
1449 ThrowMSLException(OptionError,"NoImagesDefined",
1450 (const char *) tag);
1454 NOTE: charcoal can have no attributes, since we use all the defaults!
1456 if (attributes != (const xmlChar **) NULL)
1458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1460 keyword=(const char *) attributes[i++];
1461 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1462 msl_info->attributes[n],(const char *) attributes[i],&exception));
1468 if (LocaleCompare(keyword, "bias") == 0)
1470 bias=StringToDouble(value,(char **) NULL);
1473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1479 if (LocaleCompare(keyword,"radius") == 0)
1481 radius=StringToDouble(value,(char **) NULL);
1484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1490 if (LocaleCompare(keyword,"sigma") == 0)
1492 sigma = StringToLong( value );
1495 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1500 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1514 newImage=CharcoalImage(msl_info->image[n],radius,sigma,bias,
1515 msl_info->exception);
1516 if (newImage == (Image *) NULL)
1518 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1519 msl_info->image[n]=newImage;
1523 if (LocaleCompare((const char *) tag,"chop") == 0)
1531 if (msl_info->image[n] == (Image *) NULL)
1533 ThrowMSLException(OptionError,"NoImagesDefined",
1534 (const char *) tag);
1537 SetGeometry(msl_info->image[n],&geometry);
1538 if (attributes != (const xmlChar **) NULL)
1539 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1541 keyword=(const char *) attributes[i++];
1542 attribute=InterpretImageProperties(msl_info->image_info[n],
1543 msl_info->attributes[n],(const char *) attributes[i],
1545 CloneString(&value,attribute);
1551 if (LocaleCompare(keyword,"geometry") == 0)
1553 flags=ParsePageGeometry(msl_info->image[n],value,
1554 &geometry,&exception);
1555 if ((flags & HeightValue) == 0)
1556 geometry.height=geometry.width;
1559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1566 if (LocaleCompare(keyword,"height") == 0)
1568 geometry.height=StringToLong(value);
1571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1578 if (LocaleCompare(keyword,"width") == 0)
1580 geometry.width=StringToLong(value);
1583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1590 if (LocaleCompare(keyword,"x") == 0)
1592 geometry.x=StringToLong(value);
1595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1602 if (LocaleCompare(keyword,"y") == 0)
1604 geometry.y=StringToLong(value);
1607 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1613 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1619 chop_image=ChopImage(msl_info->image[n],&geometry,
1620 msl_info->exception);
1621 if (chop_image == (Image *) NULL)
1623 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1624 msl_info->image[n]=chop_image;
1627 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1636 Color floodfill image.
1638 if (msl_info->image[n] == (Image *) NULL)
1640 ThrowMSLException(OptionError,"NoImagesDefined",
1641 (const char *) tag);
1644 draw_info=CloneDrawInfo(msl_info->image_info[n],
1645 msl_info->draw_info[n]);
1646 SetGeometry(msl_info->image[n],&geometry);
1647 paint_method=FloodfillMethod;
1648 if (attributes != (const xmlChar **) NULL)
1649 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1651 keyword=(const char *) attributes[i++];
1652 attribute=InterpretImageProperties(msl_info->image_info[n],
1653 msl_info->attributes[n],(const char *) attributes[i],
1655 CloneString(&value,attribute);
1661 if (LocaleCompare(keyword,"bordercolor") == 0)
1663 (void) QueryColorCompliance(value,AllCompliance,
1664 &target,&exception);
1665 paint_method=FillToBorderMethod;
1668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1675 if (LocaleCompare(keyword,"fill") == 0)
1677 (void) QueryColorCompliance(value,AllCompliance,
1678 &draw_info->fill,&exception);
1681 if (LocaleCompare(keyword,"fuzz") == 0)
1683 msl_info->image[n]->fuzz=StringToDouble(value,
1687 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1694 if (LocaleCompare(keyword,"geometry") == 0)
1696 flags=ParsePageGeometry(msl_info->image[n],value,
1697 &geometry,&exception);
1698 if ((flags & HeightValue) == 0)
1699 geometry.height=geometry.width;
1700 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1701 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1712 if (LocaleCompare(keyword,"x") == 0)
1714 geometry.x=StringToLong(value);
1715 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1716 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1727 if (LocaleCompare(keyword,"y") == 0)
1729 geometry.y=StringToLong(value);
1730 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1731 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1747 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1748 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1749 MagickFalse : MagickTrue,msl_info->exception);
1750 draw_info=DestroyDrawInfo(draw_info);
1753 if (LocaleCompare((const char *) tag,"comment") == 0)
1755 if (LocaleCompare((const char *) tag,"composite") == 0)
1758 composite_geometry[MaxTextExtent];
1770 if (msl_info->image[n] == (Image *) NULL)
1772 ThrowMSLException(OptionError,"NoImagesDefined",
1773 (const char *) tag);
1776 composite_image=NewImageList();
1777 compose=OverCompositeOp;
1778 if (attributes != (const xmlChar **) NULL)
1779 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1781 keyword=(const char *) attributes[i++];
1782 attribute=InterpretImageProperties(msl_info->image_info[n],
1783 msl_info->attributes[n],(const char *) attributes[i],
1785 CloneString(&value,attribute);
1791 if (LocaleCompare(keyword,"compose") == 0)
1793 option=ParseCommandOption(MagickComposeOptions,
1796 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1798 compose=(CompositeOperator) option;
1806 if (LocaleCompare(keyword,"image") == 0)
1807 for (j=0; j < msl_info->n; j++)
1812 attribute=GetImageProperty(msl_info->attributes[j],"id",
1814 if ((attribute != (const char *) NULL) &&
1815 (LocaleCompare(attribute,value) == 0))
1817 composite_image=CloneImage(msl_info->image[j],0,0,
1818 MagickFalse,&exception);
1828 if (composite_image == (Image *) NULL)
1830 rotate_image=NewImageList();
1831 SetGeometry(msl_info->image[n],&geometry);
1832 if (attributes != (const xmlChar **) NULL)
1833 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1835 keyword=(const char *) attributes[i++];
1836 attribute=InterpretImageProperties(msl_info->image_info[n],
1837 msl_info->attributes[n],(const char *) attributes[i],
1839 CloneString(&value,attribute);
1845 if (LocaleCompare(keyword,"blend") == 0)
1847 (void) SetImageArtifact(composite_image,
1848 "compose:args",value);
1851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1858 if (LocaleCompare(keyword,"channel") == 0)
1860 option=ParseChannelOption(value);
1862 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1864 channel=(ChannelType) option;
1867 if (LocaleCompare(keyword, "color") == 0)
1869 (void) QueryColorCompliance(value,AllCompliance,
1870 &composite_image->background_color,&exception);
1873 if (LocaleCompare(keyword,"compose") == 0)
1875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1882 if (LocaleCompare(keyword,"geometry") == 0)
1884 flags=ParsePageGeometry(msl_info->image[n],value,
1885 &geometry,&exception);
1886 if ((flags & HeightValue) == 0)
1887 geometry.height=geometry.width;
1890 if (LocaleCompare(keyword,"gravity") == 0)
1892 option=ParseCommandOption(MagickGravityOptions,
1895 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1897 msl_info->image[n]->gravity=(GravityType) option;
1900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1907 if (LocaleCompare(keyword,"image") == 0)
1909 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1916 if (LocaleCompare(keyword,"mask") == 0)
1917 for (j=0; j < msl_info->n; j++)
1922 attribute=GetImageProperty(msl_info->attributes[j],"id",
1924 if ((attribute != (const char *) NULL) &&
1925 (LocaleCompare(value,value) == 0))
1927 SetImageType(composite_image,TrueColorMatteType,
1929 (void) CompositeImage(composite_image,
1930 CopyAlphaCompositeOp,msl_info->image[j],0,0,
1935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1942 if (LocaleCompare(keyword,"opacity") == 0)
1957 opacity=StringToLong(value);
1958 if (compose != DissolveCompositeOp)
1960 (void) SetImageAlpha(composite_image,(Quantum)
1961 opacity,&exception);
1964 (void) SetImageArtifact(msl_info->image[n],
1965 "compose:args",value);
1966 if (composite_image->matte != MagickTrue)
1967 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1969 composite_view=AcquireCacheView(composite_image);
1970 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1972 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1973 (ssize_t) composite_image->columns,1,&exception);
1974 for (x=0; x < (ssize_t) composite_image->columns; x++)
1976 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1977 SetPixelAlpha(composite_image,
1978 ClampToQuantum(opacity),q);
1979 q+=GetPixelChannels(composite_image);
1981 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1984 composite_view=DestroyCacheView(composite_view);
1987 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1994 if (LocaleCompare(keyword,"rotate") == 0)
1996 rotate_image=RotateImage(composite_image,
1997 StringToDouble(value,(char **) NULL),&exception);
2000 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2007 if (LocaleCompare(keyword,"tile") == 0)
2012 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2015 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2017 tile=(MagickBooleanType) option;
2019 if (rotate_image != (Image *) NULL)
2020 (void) SetImageArtifact(rotate_image,
2021 "compose:outside-overlay","false");
2023 (void) SetImageArtifact(composite_image,
2024 "compose:outside-overlay","false");
2025 image=msl_info->image[n];
2026 height=composite_image->rows;
2027 width=composite_image->columns;
2028 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2029 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2031 if (rotate_image != (Image *) NULL)
2032 (void) CompositeImage(image,compose,rotate_image,
2035 (void) CompositeImage(image,compose,
2036 composite_image,x,y,&exception);
2038 if (rotate_image != (Image *) NULL)
2039 rotate_image=DestroyImage(rotate_image);
2042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2049 if (LocaleCompare(keyword,"x") == 0)
2051 geometry.x=StringToLong(value);
2054 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2061 if (LocaleCompare(keyword,"y") == 0)
2063 geometry.y=StringToLong(value);
2066 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2072 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2078 image=msl_info->image[n];
2079 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2080 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2081 (double) composite_image->rows,(double) geometry.x,(double)
2083 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2085 channel_mask=SetPixelChannelMask(image,channel);
2086 if (rotate_image == (Image *) NULL)
2087 CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
2094 geometry.x-=(ssize_t) (rotate_image->columns-
2095 composite_image->columns)/2;
2096 geometry.y-=(ssize_t) (rotate_image->rows-
2097 composite_image->rows)/2;
2098 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
2100 rotate_image=DestroyImage(rotate_image);
2102 (void) SetPixelChannelMask(image,channel_mask);
2103 composite_image=DestroyImage(composite_image);
2106 if (LocaleCompare((const char *) tag,"contrast") == 0)
2114 if (msl_info->image[n] == (Image *) NULL)
2116 ThrowMSLException(OptionError,"NoImagesDefined",
2117 (const char *) tag);
2120 sharpen=MagickFalse;
2121 if (attributes != (const xmlChar **) NULL)
2122 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2124 keyword=(const char *) attributes[i++];
2125 attribute=InterpretImageProperties(msl_info->image_info[n],
2126 msl_info->attributes[n],(const char *) attributes[i],
2128 CloneString(&value,attribute);
2134 if (LocaleCompare(keyword,"sharpen") == 0)
2136 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2139 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2141 sharpen=(MagickBooleanType) option;
2144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2150 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2156 (void) ContrastImage(msl_info->image[n],sharpen,
2157 msl_info->exception);
2160 if (LocaleCompare((const char *) tag,"crop") == 0)
2168 if (msl_info->image[n] == (Image *) NULL)
2170 ThrowMSLException(OptionError,"NoImagesDefined",
2171 (const char *) tag);
2174 SetGeometry(msl_info->image[n],&geometry);
2175 if (attributes != (const xmlChar **) NULL)
2176 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2178 keyword=(const char *) attributes[i++];
2179 attribute=InterpretImageProperties(msl_info->image_info[n],
2180 msl_info->attributes[n],(const char *) attributes[i],
2182 CloneString(&value,attribute);
2188 if (LocaleCompare(keyword,"geometry") == 0)
2190 flags=ParseGravityGeometry(msl_info->image[n],value,
2191 &geometry,&exception);
2194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2201 if (LocaleCompare(keyword,"height") == 0)
2203 geometry.height=StringToLong(value);
2206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2213 if (LocaleCompare(keyword,"width") == 0)
2215 geometry.width=StringToLong(value);
2218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2225 if (LocaleCompare(keyword,"x") == 0)
2227 geometry.x=StringToLong(value);
2230 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2237 if (LocaleCompare(keyword,"y") == 0)
2239 geometry.y=StringToLong(value);
2242 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2248 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2254 crop_image=CropImage(msl_info->image[n],&geometry,
2255 msl_info->exception);
2256 if (crop_image == (Image *) NULL)
2258 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2259 msl_info->image[n]=crop_image;
2262 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2268 Cycle-colormap image.
2270 if (msl_info->image[n] == (Image *) NULL)
2272 ThrowMSLException(OptionError,"NoImagesDefined",
2273 (const char *) tag);
2277 if (attributes != (const xmlChar **) NULL)
2278 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2280 keyword=(const char *) attributes[i++];
2281 attribute=InterpretImageProperties(msl_info->image_info[n],
2282 msl_info->attributes[n],(const char *) attributes[i],
2284 CloneString(&value,attribute);
2290 if (LocaleCompare(keyword,"display") == 0)
2292 display=StringToLong(value);
2295 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2301 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2307 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2310 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2315 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2323 if (msl_info->image[n] == (Image *) NULL)
2325 ThrowMSLException(OptionError,"NoImagesDefined",
2326 (const char *) tag);
2329 if (attributes != (const xmlChar **) NULL)
2330 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2332 keyword=(const char *) attributes[i++];
2333 attribute=InterpretImageProperties(msl_info->image_info[n],
2334 msl_info->attributes[n],(const char *) attributes[i],
2336 CloneString(&value,attribute);
2337 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2339 despeckle_image=DespeckleImage(msl_info->image[n],
2340 msl_info->exception);
2341 if (despeckle_image == (Image *) NULL)
2343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2344 msl_info->image[n]=despeckle_image;
2347 if (LocaleCompare((const char *) tag,"display") == 0)
2349 if (msl_info->image[n] == (Image *) NULL)
2351 ThrowMSLException(OptionError,"NoImagesDefined",
2352 (const char *) tag);
2355 if (attributes != (const xmlChar **) NULL)
2356 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2358 keyword=(const char *) attributes[i++];
2359 attribute=InterpretImageProperties(msl_info->image_info[n],
2360 msl_info->attributes[n],(const char *) attributes[i],
2362 CloneString(&value,attribute);
2367 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2373 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2374 msl_info->exception);
2377 if (LocaleCompare((const char *) tag,"draw") == 0)
2380 text[MaxTextExtent];
2385 if (msl_info->image[n] == (Image *) NULL)
2387 ThrowMSLException(OptionError,"NoImagesDefined",
2388 (const char *) tag);
2391 draw_info=CloneDrawInfo(msl_info->image_info[n],
2392 msl_info->draw_info[n]);
2394 current=draw_info->affine;
2395 GetAffineMatrix(&affine);
2396 if (attributes != (const xmlChar **) NULL)
2397 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2399 keyword=(const char *) attributes[i++];
2400 attribute=InterpretImageProperties(msl_info->image_info[n],
2401 msl_info->attributes[n],(const char *) attributes[i],
2403 CloneString(&value,attribute);
2409 if (LocaleCompare(keyword,"affine") == 0)
2415 draw_info->affine.sx=StringToDouble(p,&p);
2418 draw_info->affine.rx=StringToDouble(p,&p);
2421 draw_info->affine.ry=StringToDouble(p,&p);
2424 draw_info->affine.sy=StringToDouble(p,&p);
2427 draw_info->affine.tx=StringToDouble(p,&p);
2430 draw_info->affine.ty=StringToDouble(p,&p);
2433 if (LocaleCompare(keyword,"align") == 0)
2435 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2438 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2440 draw_info->align=(AlignType) option;
2443 if (LocaleCompare(keyword,"antialias") == 0)
2445 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2448 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2450 draw_info->stroke_antialias=(MagickBooleanType) option;
2451 draw_info->text_antialias=(MagickBooleanType) option;
2454 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2461 if (LocaleCompare(keyword,"density") == 0)
2463 CloneString(&draw_info->density,value);
2466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2473 if (LocaleCompare(keyword,"encoding") == 0)
2475 CloneString(&draw_info->encoding,value);
2478 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2485 if (LocaleCompare(keyword, "fill") == 0)
2487 (void) QueryColorCompliance(value,AllCompliance,
2488 &draw_info->fill,&exception);
2491 if (LocaleCompare(keyword,"family") == 0)
2493 CloneString(&draw_info->family,value);
2496 if (LocaleCompare(keyword,"font") == 0)
2498 CloneString(&draw_info->font,value);
2501 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2508 if (LocaleCompare(keyword,"geometry") == 0)
2510 flags=ParsePageGeometry(msl_info->image[n],value,
2511 &geometry,&exception);
2512 if ((flags & HeightValue) == 0)
2513 geometry.height=geometry.width;
2516 if (LocaleCompare(keyword,"gravity") == 0)
2518 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2521 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2523 draw_info->gravity=(GravityType) option;
2526 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2533 if (LocaleCompare(keyword,"primitive") == 0)
2535 CloneString(&draw_info->primitive,value);
2538 if (LocaleCompare(keyword,"pointsize") == 0)
2540 draw_info->pointsize=StringToDouble(value,
2544 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2551 if (LocaleCompare(keyword,"rotate") == 0)
2553 angle=StringToDouble(value,(char **) NULL);
2554 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2555 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2556 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2557 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2567 if (LocaleCompare(keyword,"scale") == 0)
2569 flags=ParseGeometry(value,&geometry_info);
2570 if ((flags & SigmaValue) == 0)
2571 geometry_info.sigma=1.0;
2572 affine.sx=geometry_info.rho;
2573 affine.sy=geometry_info.sigma;
2576 if (LocaleCompare(keyword,"skewX") == 0)
2578 angle=StringToDouble(value,(char **) NULL);
2579 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2582 if (LocaleCompare(keyword,"skewY") == 0)
2584 angle=StringToDouble(value,(char **) NULL);
2585 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2588 if (LocaleCompare(keyword,"stretch") == 0)
2590 option=ParseCommandOption(MagickStretchOptions,
2593 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2595 draw_info->stretch=(StretchType) option;
2598 if (LocaleCompare(keyword, "stroke") == 0)
2600 (void) QueryColorCompliance(value,AllCompliance,
2601 &draw_info->stroke,&exception);
2604 if (LocaleCompare(keyword,"strokewidth") == 0)
2606 draw_info->stroke_width=StringToLong(value);
2609 if (LocaleCompare(keyword,"style") == 0)
2611 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2614 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2616 draw_info->style=(StyleType) option;
2619 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2626 if (LocaleCompare(keyword,"text") == 0)
2628 CloneString(&draw_info->text,value);
2631 if (LocaleCompare(keyword,"translate") == 0)
2633 flags=ParseGeometry(value,&geometry_info);
2634 if ((flags & SigmaValue) == 0)
2635 geometry_info.sigma=1.0;
2636 affine.tx=geometry_info.rho;
2637 affine.ty=geometry_info.sigma;
2640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2647 if (LocaleCompare(keyword, "undercolor") == 0)
2649 (void) QueryColorCompliance(value,AllCompliance,
2650 &draw_info->undercolor,&exception);
2653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2660 if (LocaleCompare(keyword,"weight") == 0)
2662 draw_info->weight=StringToLong(value);
2665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2672 if (LocaleCompare(keyword,"x") == 0)
2674 geometry.x=StringToLong(value);
2677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2684 if (LocaleCompare(keyword,"y") == 0)
2686 geometry.y=StringToLong(value);
2689 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2701 (void) FormatLocaleString(text,MaxTextExtent,
2702 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2703 geometry.height,(double) geometry.x,(double) geometry.y);
2704 CloneString(&draw_info->geometry,text);
2705 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2706 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2707 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2708 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2709 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2711 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2713 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2714 draw_info=DestroyDrawInfo(draw_info);
2717 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2722 if (LocaleCompare((const char *) tag,"edge") == 0)
2730 if (msl_info->image[n] == (Image *) NULL)
2732 ThrowMSLException(OptionError,"NoImagesDefined",
2733 (const char *) tag);
2736 if (attributes != (const xmlChar **) NULL)
2737 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2739 keyword=(const char *) attributes[i++];
2740 attribute=InterpretImageProperties(msl_info->image_info[n],
2741 msl_info->attributes[n],(const char *) attributes[i],
2743 CloneString(&value,attribute);
2749 if (LocaleCompare(keyword,"geometry") == 0)
2751 flags=ParseGeometry(value,&geometry_info);
2752 if ((flags & SigmaValue) == 0)
2753 geometry_info.sigma=1.0;
2756 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2763 if (LocaleCompare(keyword,"radius") == 0)
2765 geometry_info.rho=StringToDouble(value,(char **) NULL);
2768 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2780 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2781 geometry_info.sigma,msl_info->exception);
2782 if (edge_image == (Image *) NULL)
2784 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2785 msl_info->image[n]=edge_image;
2788 if (LocaleCompare((const char *) tag,"emboss") == 0)
2796 if (msl_info->image[n] == (Image *) NULL)
2798 ThrowMSLException(OptionError,"NoImagesDefined",
2799 (const char *) tag);
2802 if (attributes != (const xmlChar **) NULL)
2803 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2805 keyword=(const char *) attributes[i++];
2806 attribute=InterpretImageProperties(msl_info->image_info[n],
2807 msl_info->attributes[n],(const char *) attributes[i],
2809 CloneString(&value,attribute);
2815 if (LocaleCompare(keyword,"geometry") == 0)
2817 flags=ParseGeometry(value,&geometry_info);
2818 if ((flags & SigmaValue) == 0)
2819 geometry_info.sigma=1.0;
2822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2829 if (LocaleCompare(keyword,"radius") == 0)
2831 geometry_info.rho=StringToDouble(value,
2835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2842 if (LocaleCompare(keyword,"sigma") == 0)
2844 geometry_info.sigma=StringToLong(value);
2847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2859 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2860 geometry_info.sigma,msl_info->exception);
2861 if (emboss_image == (Image *) NULL)
2863 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2864 msl_info->image[n]=emboss_image;
2867 if (LocaleCompare((const char *) tag,"enhance") == 0)
2875 if (msl_info->image[n] == (Image *) NULL)
2877 ThrowMSLException(OptionError,"NoImagesDefined",
2878 (const char *) tag);
2881 if (attributes != (const xmlChar **) NULL)
2882 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2884 keyword=(const char *) attributes[i++];
2885 attribute=InterpretImageProperties(msl_info->image_info[n],
2886 msl_info->attributes[n],(const char *) attributes[i],
2888 CloneString(&value,attribute);
2889 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2891 enhance_image=EnhanceImage(msl_info->image[n],
2892 msl_info->exception);
2893 if (enhance_image == (Image *) NULL)
2895 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2896 msl_info->image[n]=enhance_image;
2899 if (LocaleCompare((const char *) tag,"equalize") == 0)
2904 if (msl_info->image[n] == (Image *) NULL)
2906 ThrowMSLException(OptionError,"NoImagesDefined",
2907 (const char *) tag);
2910 if (attributes != (const xmlChar **) NULL)
2911 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2913 keyword=(const char *) attributes[i++];
2914 attribute=InterpretImageProperties(msl_info->image_info[n],
2915 msl_info->attributes[n],(const char *) attributes[i],
2917 CloneString(&value,attribute);
2922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2928 (void) EqualizeImage(msl_info->image[n],
2929 msl_info->exception);
2932 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2937 if (LocaleCompare((const char *) tag, "flatten") == 0)
2939 if (msl_info->image[n] == (Image *) NULL)
2941 ThrowMSLException(OptionError,"NoImagesDefined",
2942 (const char *) tag);
2946 /* no attributes here */
2948 /* process the image */
2953 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2954 msl_info->exception);
2955 if (newImage == (Image *) NULL)
2957 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2958 msl_info->image[n]=newImage;
2962 if (LocaleCompare((const char *) tag,"flip") == 0)
2970 if (msl_info->image[n] == (Image *) NULL)
2972 ThrowMSLException(OptionError,"NoImagesDefined",
2973 (const char *) tag);
2976 if (attributes != (const xmlChar **) NULL)
2977 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2979 keyword=(const char *) attributes[i++];
2980 attribute=InterpretImageProperties(msl_info->image_info[n],
2981 msl_info->attributes[n],(const char *) attributes[i],
2983 CloneString(&value,attribute);
2984 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2986 flip_image=FlipImage(msl_info->image[n],
2987 msl_info->exception);
2988 if (flip_image == (Image *) NULL)
2990 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2991 msl_info->image[n]=flip_image;
2994 if (LocaleCompare((const char *) tag,"flop") == 0)
3002 if (msl_info->image[n] == (Image *) NULL)
3004 ThrowMSLException(OptionError,"NoImagesDefined",
3005 (const char *) tag);
3008 if (attributes != (const xmlChar **) NULL)
3009 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3011 keyword=(const char *) attributes[i++];
3012 attribute=InterpretImageProperties(msl_info->image_info[n],
3013 msl_info->attributes[n],(const char *) attributes[i],
3015 CloneString(&value,attribute);
3016 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3018 flop_image=FlopImage(msl_info->image[n],
3019 msl_info->exception);
3020 if (flop_image == (Image *) NULL)
3022 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3023 msl_info->image[n]=flop_image;
3026 if (LocaleCompare((const char *) tag,"frame") == 0)
3037 if (msl_info->image[n] == (Image *) NULL)
3039 ThrowMSLException(OptionError,"NoImagesDefined",
3040 (const char *) tag);
3043 SetGeometry(msl_info->image[n],&geometry);
3044 if (attributes != (const xmlChar **) NULL)
3045 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3047 keyword=(const char *) attributes[i++];
3048 attribute=InterpretImageProperties(msl_info->image_info[n],
3049 msl_info->attributes[n],(const char *) attributes[i],
3051 CloneString(&value,attribute);
3057 if (LocaleCompare(keyword,"compose") == 0)
3059 option=ParseCommandOption(MagickComposeOptions,
3062 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3064 msl_info->image[n]->compose=(CompositeOperator) option;
3067 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3074 if (LocaleCompare(keyword, "fill") == 0)
3076 (void) QueryColorCompliance(value,AllCompliance,
3077 &msl_info->image[n]->matte_color,&exception);
3080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3087 if (LocaleCompare(keyword,"geometry") == 0)
3089 flags=ParsePageGeometry(msl_info->image[n],value,
3090 &geometry,&exception);
3091 if ((flags & HeightValue) == 0)
3092 geometry.height=geometry.width;
3093 frame_info.width=geometry.width;
3094 frame_info.height=geometry.height;
3095 frame_info.outer_bevel=geometry.x;
3096 frame_info.inner_bevel=geometry.y;
3099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3106 if (LocaleCompare(keyword,"height") == 0)
3108 frame_info.height=StringToLong(value);
3111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3118 if (LocaleCompare(keyword,"inner") == 0)
3120 frame_info.inner_bevel=StringToLong(value);
3123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3130 if (LocaleCompare(keyword,"outer") == 0)
3132 frame_info.outer_bevel=StringToLong(value);
3135 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3142 if (LocaleCompare(keyword,"width") == 0)
3144 frame_info.width=StringToLong(value);
3147 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3153 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3159 frame_info.x=(ssize_t) frame_info.width;
3160 frame_info.y=(ssize_t) frame_info.height;
3161 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3162 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3163 frame_image=FrameImage(msl_info->image[n],&frame_info,
3164 msl_info->image[n]->compose,msl_info->exception);
3165 if (frame_image == (Image *) NULL)
3167 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3168 msl_info->image[n]=frame_image;
3171 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3176 if (LocaleCompare((const char *) tag,"gamma") == 0)
3179 gamma[MaxTextExtent];
3187 if (msl_info->image[n] == (Image *) NULL)
3189 ThrowMSLException(OptionError,"NoImagesDefined",
3190 (const char *) tag);
3193 channel=UndefinedChannel;
3198 if (attributes != (const xmlChar **) NULL)
3199 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3201 keyword=(const char *) attributes[i++];
3202 attribute=InterpretImageProperties(msl_info->image_info[n],
3203 msl_info->attributes[n],(const char *) attributes[i],
3205 CloneString(&value,attribute);
3211 if (LocaleCompare(keyword,"blue") == 0)
3213 pixel.blue=StringToDouble(value,(char **) NULL);
3216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3223 if (LocaleCompare(keyword,"channel") == 0)
3225 option=ParseChannelOption(value);
3227 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3229 channel=(ChannelType) option;
3232 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3239 if (LocaleCompare(keyword,"gamma") == 0)
3241 (void) CopyMagickString(gamma,value,MaxTextExtent);
3244 if (LocaleCompare(keyword,"green") == 0)
3246 pixel.green=StringToDouble(value,(char **) NULL);
3249 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3256 if (LocaleCompare(keyword,"red") == 0)
3258 pixel.red=StringToDouble(value,(char **) NULL);
3261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3267 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3274 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3275 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3276 (void) GammaImage(msl_info->image[n],atof(gamma),
3277 msl_info->exception);
3280 else if (LocaleCompare((const char *) tag,"get") == 0)
3282 if (msl_info->image[n] == (Image *) NULL)
3284 ThrowMSLException(OptionError,"NoImagesDefined",
3285 (const char *) tag);
3288 if (attributes == (const xmlChar **) NULL)
3290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3292 keyword=(const char *) attributes[i++];
3293 CloneString(&value,(const char *) attributes[i]);
3294 (void) CopyMagickString(key,value,MaxTextExtent);
3300 if (LocaleCompare(keyword,"height") == 0)
3302 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3303 (double) msl_info->image[n]->rows);
3304 (void) SetImageProperty(msl_info->attributes[n],key,value,
3308 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3313 if (LocaleCompare(keyword,"width") == 0)
3315 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3316 (double) msl_info->image[n]->columns);
3317 (void) SetImageProperty(msl_info->attributes[n],key,value,
3321 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3325 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3332 else if (LocaleCompare((const char *) tag, "group") == 0)
3334 msl_info->number_groups++;
3335 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3336 msl_info->group_info,msl_info->number_groups+1UL,
3337 sizeof(*msl_info->group_info));
3340 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3345 if (LocaleCompare((const char *) tag,"image") == 0)
3347 MSLPushImage(msl_info,(Image *) NULL);
3348 if (attributes == (const xmlChar **) NULL)
3350 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3352 keyword=(const char *) attributes[i++];
3353 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3354 msl_info->attributes[n],(const char *) attributes[i],&exception));
3360 if (LocaleCompare(keyword,"color") == 0)
3365 (void) CopyMagickString(msl_info->image_info[n]->filename,
3366 "xc:",MaxTextExtent);
3367 (void) ConcatenateMagickString(msl_info->image_info[n]->
3368 filename,value,MaxTextExtent);
3369 next_image=ReadImage(msl_info->image_info[n],&exception);
3370 CatchException(&exception);
3371 if (next_image == (Image *) NULL)
3373 if (msl_info->image[n] == (Image *) NULL)
3374 msl_info->image[n]=next_image;
3381 Link image into image list.
3383 p=msl_info->image[n];
3384 while (p->next != (Image *) NULL)
3385 p=GetNextImageInList(p);
3386 next_image->previous=p;
3391 (void) SetMSLAttributes(msl_info,keyword,value);
3396 (void) SetMSLAttributes(msl_info,keyword,value);
3403 if (LocaleCompare((const char *) tag,"implode") == 0)
3411 if (msl_info->image[n] == (Image *) NULL)
3413 ThrowMSLException(OptionError,"NoImagesDefined",
3414 (const char *) tag);
3417 if (attributes != (const xmlChar **) NULL)
3418 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3420 keyword=(const char *) attributes[i++];
3421 attribute=InterpretImageProperties(msl_info->image_info[n],
3422 msl_info->attributes[n],(const char *) attributes[i],
3424 CloneString(&value,attribute);
3430 if (LocaleCompare(keyword,"amount") == 0)
3432 geometry_info.rho=StringToDouble(value,
3436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3443 if (LocaleCompare(keyword,"geometry") == 0)
3445 flags=ParseGeometry(value,&geometry_info);
3446 if ((flags & SigmaValue) == 0)
3447 geometry_info.sigma=1.0;
3450 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3462 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3463 msl_info->image[n]->interpolate,msl_info->exception);
3464 if (implode_image == (Image *) NULL)
3466 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3467 msl_info->image[n]=implode_image;
3470 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3475 if (LocaleCompare((const char *) tag,"label") == 0)
3477 if (LocaleCompare((const char *) tag, "level") == 0)
3480 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3482 if (msl_info->image[n] == (Image *) NULL)
3484 ThrowMSLException(OptionError,"NoImagesDefined",
3485 (const char *) tag);
3488 if (attributes == (const xmlChar **) NULL)
3490 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3492 keyword=(const char *) attributes[i++];
3493 CloneString(&value,(const char *) attributes[i]);
3494 (void) CopyMagickString(key,value,MaxTextExtent);
3500 if (LocaleCompare(keyword,"black") == 0)
3502 levelBlack = StringToDouble(value,(char **) NULL);
3505 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3511 if (LocaleCompare(keyword,"gamma") == 0)
3513 levelGamma = StringToDouble(value,(char **) NULL);
3516 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3522 if (LocaleCompare(keyword,"white") == 0)
3524 levelWhite = StringToDouble(value,(char **) NULL);
3527 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3539 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3540 msl_info->exception);
3547 if (LocaleCompare((const char *) tag,"magnify") == 0)
3555 if (msl_info->image[n] == (Image *) NULL)
3557 ThrowMSLException(OptionError,"NoImagesDefined",
3558 (const char *) tag);
3561 if (attributes != (const xmlChar **) NULL)
3562 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3564 keyword=(const char *) attributes[i++];
3565 attribute=InterpretImageProperties(msl_info->image_info[n],
3566 msl_info->attributes[n],(const char *) attributes[i],
3568 CloneString(&value,attribute);
3569 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3571 magnify_image=MagnifyImage(msl_info->image[n],
3572 msl_info->exception);
3573 if (magnify_image == (Image *) NULL)
3575 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3576 msl_info->image[n]=magnify_image;
3579 if (LocaleCompare((const char *) tag,"map") == 0)
3593 if (msl_info->image[n] == (Image *) NULL)
3595 ThrowMSLException(OptionError,"NoImagesDefined",
3596 (const char *) tag);
3599 affinity_image=NewImageList();
3601 if (attributes != (const xmlChar **) NULL)
3602 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3604 keyword=(const char *) attributes[i++];
3605 attribute=InterpretImageProperties(msl_info->image_info[n],
3606 msl_info->attributes[n],(const char *) attributes[i],
3608 CloneString(&value,attribute);
3614 if (LocaleCompare(keyword,"dither") == 0)
3616 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3619 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3621 dither=(MagickBooleanType) option;
3624 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3631 if (LocaleCompare(keyword,"image") == 0)
3632 for (j=0; j < msl_info->n; j++)
3637 attribute=GetImageProperty(msl_info->attributes[j],"id",
3639 if ((attribute != (const char *) NULL) &&
3640 (LocaleCompare(attribute,value) == 0))
3642 affinity_image=CloneImage(msl_info->image[j],0,0,
3643 MagickFalse,&exception);
3651 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3657 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3658 quantize_info->dither=dither;
3659 (void) RemapImages(quantize_info,msl_info->image[n],
3660 affinity_image,&exception);
3661 quantize_info=DestroyQuantizeInfo(quantize_info);
3662 affinity_image=DestroyImage(affinity_image);
3665 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3677 Matte floodfill image.
3680 if (msl_info->image[n] == (Image *) NULL)
3682 ThrowMSLException(OptionError,"NoImagesDefined",
3683 (const char *) tag);
3686 SetGeometry(msl_info->image[n],&geometry);
3687 paint_method=FloodfillMethod;
3688 if (attributes != (const xmlChar **) NULL)
3689 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3691 keyword=(const char *) attributes[i++];
3692 attribute=InterpretImageProperties(msl_info->image_info[n],
3693 msl_info->attributes[n],(const char *) attributes[i],
3695 CloneString(&value,attribute);
3701 if (LocaleCompare(keyword,"bordercolor") == 0)
3703 (void) QueryColorCompliance(value,AllCompliance,
3704 &target,&exception);
3705 paint_method=FillToBorderMethod;
3708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3715 if (LocaleCompare(keyword,"fuzz") == 0)
3717 msl_info->image[n]->fuzz=StringToDouble(value,
3721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3728 if (LocaleCompare(keyword,"geometry") == 0)
3730 flags=ParsePageGeometry(msl_info->image[n],value,
3731 &geometry,&exception);
3732 if ((flags & HeightValue) == 0)
3733 geometry.height=geometry.width;
3734 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3735 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3746 if (LocaleCompare(keyword,"opacity") == 0)
3748 opacity=StringToDouble(value,(char **) NULL);
3751 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3758 if (LocaleCompare(keyword,"x") == 0)
3760 geometry.x=StringToLong(value);
3761 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3762 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3766 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3773 if (LocaleCompare(keyword,"y") == 0)
3775 geometry.y=StringToLong(value);
3776 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3777 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3781 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3793 draw_info=CloneDrawInfo(msl_info->image_info[n],
3794 msl_info->draw_info[n]);
3795 draw_info->fill.alpha=ClampToQuantum(opacity);
3796 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3797 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3798 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3799 MagickFalse : MagickTrue,msl_info->exception);
3800 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
3801 draw_info=DestroyDrawInfo(draw_info);
3804 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3810 Median-filter image.
3812 if (msl_info->image[n] == (Image *) NULL)
3814 ThrowMSLException(OptionError,"NoImagesDefined",
3815 (const char *) tag);
3818 if (attributes != (const xmlChar **) NULL)
3819 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3821 keyword=(const char *) attributes[i++];
3822 attribute=InterpretImageProperties(msl_info->image_info[n],
3823 msl_info->attributes[n],(const char *) attributes[i],
3825 CloneString(&value,attribute);
3831 if (LocaleCompare(keyword,"geometry") == 0)
3833 flags=ParseGeometry(value,&geometry_info);
3834 if ((flags & SigmaValue) == 0)
3835 geometry_info.sigma=1.0;
3838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3845 if (LocaleCompare(keyword,"radius") == 0)
3847 geometry_info.rho=StringToDouble(value,
3851 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3857 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3863 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3864 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3865 msl_info->exception);
3866 if (median_image == (Image *) NULL)
3868 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3869 msl_info->image[n]=median_image;
3872 if (LocaleCompare((const char *) tag,"minify") == 0)
3880 if (msl_info->image[n] == (Image *) NULL)
3882 ThrowMSLException(OptionError,"NoImagesDefined",
3883 (const char *) tag);
3886 if (attributes != (const xmlChar **) NULL)
3887 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3889 keyword=(const char *) attributes[i++];
3890 attribute=InterpretImageProperties(msl_info->image_info[n],
3891 msl_info->attributes[n],(const char *) attributes[i],
3893 CloneString(&value,attribute);
3894 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3896 minify_image=MinifyImage(msl_info->image[n],
3897 msl_info->exception);
3898 if (minify_image == (Image *) NULL)
3900 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3901 msl_info->image[n]=minify_image;
3904 if (LocaleCompare((const char *) tag,"msl") == 0 )
3906 if (LocaleCompare((const char *) tag,"modulate") == 0)
3909 modulate[MaxTextExtent];
3914 if (msl_info->image[n] == (Image *) NULL)
3916 ThrowMSLException(OptionError,"NoImagesDefined",
3917 (const char *) tag);
3920 geometry_info.rho=100.0;
3921 geometry_info.sigma=100.0;
3922 geometry_info.xi=100.0;
3923 if (attributes != (const xmlChar **) NULL)
3924 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3926 keyword=(const char *) attributes[i++];
3927 attribute=InterpretImageProperties(msl_info->image_info[n],
3928 msl_info->attributes[n],(const char *) attributes[i],
3930 CloneString(&value,attribute);
3936 if (LocaleCompare(keyword,"blackness") == 0)
3938 geometry_info.rho=StringToDouble(value,
3942 if (LocaleCompare(keyword,"brightness") == 0)
3944 geometry_info.rho=StringToDouble(value,
3948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3955 if (LocaleCompare(keyword,"factor") == 0)
3957 flags=ParseGeometry(value,&geometry_info);
3960 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3967 if (LocaleCompare(keyword,"hue") == 0)
3969 geometry_info.xi=StringToDouble(value,
3973 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3980 if (LocaleCompare(keyword,"lightness") == 0)
3982 geometry_info.rho=StringToDouble(value,
3986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3993 if (LocaleCompare(keyword,"saturation") == 0)
3995 geometry_info.sigma=StringToDouble(value,
3999 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4006 if (LocaleCompare(keyword,"whiteness") == 0)
4008 geometry_info.sigma=StringToDouble(value,
4012 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4018 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4024 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4025 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4026 (void) ModulateImage(msl_info->image[n],modulate,
4027 msl_info->exception);
4030 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4035 if (LocaleCompare((const char *) tag,"negate") == 0)
4043 if (msl_info->image[n] == (Image *) NULL)
4045 ThrowMSLException(OptionError,"NoImagesDefined",
4046 (const char *) tag);
4050 if (attributes != (const xmlChar **) NULL)
4051 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4053 keyword=(const char *) attributes[i++];
4054 attribute=InterpretImageProperties(msl_info->image_info[n],
4055 msl_info->attributes[n],(const char *) attributes[i],
4057 CloneString(&value,attribute);
4063 if (LocaleCompare(keyword,"channel") == 0)
4065 option=ParseChannelOption(value);
4067 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4069 channel=(ChannelType) option;
4072 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4079 if (LocaleCompare(keyword,"gray") == 0)
4081 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4084 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4086 gray=(MagickBooleanType) option;
4089 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4095 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4101 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4102 (void) NegateImage(msl_info->image[n],gray,
4103 msl_info->exception);
4104 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4107 if (LocaleCompare((const char *) tag,"normalize") == 0)
4112 if (msl_info->image[n] == (Image *) NULL)
4114 ThrowMSLException(OptionError,"NoImagesDefined",
4115 (const char *) tag);
4118 if (attributes != (const xmlChar **) NULL)
4119 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4121 keyword=(const char *) attributes[i++];
4122 attribute=InterpretImageProperties(msl_info->image_info[n],
4123 msl_info->attributes[n],(const char *) attributes[i],
4125 CloneString(&value,attribute);
4131 if (LocaleCompare(keyword,"channel") == 0)
4133 option=ParseChannelOption(value);
4135 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4137 channel=(ChannelType) option;
4140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 (void) NormalizeImage(msl_info->image[n],
4153 msl_info->exception);
4156 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4161 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4169 if (msl_info->image[n] == (Image *) NULL)
4171 ThrowMSLException(OptionError,"NoImagesDefined",
4172 (const char *) tag);
4175 if (attributes != (const xmlChar **) NULL)
4176 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4178 keyword=(const char *) attributes[i++];
4179 attribute=InterpretImageProperties(msl_info->image_info[n],
4180 msl_info->attributes[n],(const char *) attributes[i],
4182 CloneString(&value,attribute);
4188 if (LocaleCompare(keyword,"geometry") == 0)
4190 flags=ParseGeometry(value,&geometry_info);
4191 if ((flags & SigmaValue) == 0)
4192 geometry_info.sigma=1.0;
4195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4202 if (LocaleCompare(keyword,"radius") == 0)
4204 geometry_info.rho=StringToDouble(value,
4208 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4220 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4221 geometry_info.sigma,msl_info->exception);
4222 if (paint_image == (Image *) NULL)
4224 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4225 msl_info->image[n]=paint_image;
4228 if (LocaleCompare((const char *) tag,"opaque") == 0)
4237 if (msl_info->image[n] == (Image *) NULL)
4239 ThrowMSLException(OptionError,"NoImagesDefined",
4240 (const char *) tag);
4243 (void) QueryColorCompliance("none",AllCompliance,&target,
4245 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4247 if (attributes != (const xmlChar **) NULL)
4248 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4250 keyword=(const char *) attributes[i++];
4251 attribute=InterpretImageProperties(msl_info->image_info[n],
4252 msl_info->attributes[n],(const char *) attributes[i],
4254 CloneString(&value,attribute);
4260 if (LocaleCompare(keyword,"channel") == 0)
4262 option=ParseChannelOption(value);
4264 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4266 channel=(ChannelType) option;
4269 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4276 if (LocaleCompare(keyword,"fill") == 0)
4278 (void) QueryColorCompliance(value,AllCompliance,
4279 &fill_color,&exception);
4282 if (LocaleCompare(keyword,"fuzz") == 0)
4284 msl_info->image[n]->fuzz=StringToDouble(value,
4288 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4294 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4300 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4301 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4302 MagickFalse,msl_info->exception);
4303 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4306 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4311 if (LocaleCompare((const char *) tag,"print") == 0)
4313 if (attributes == (const xmlChar **) NULL)
4315 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4317 keyword=(const char *) attributes[i++];
4318 attribute=InterpretImageProperties(msl_info->image_info[n],
4319 msl_info->attributes[n],(const char *) attributes[i],
4321 CloneString(&value,attribute);
4327 if (LocaleCompare(keyword,"output") == 0)
4329 (void) FormatLocaleFile(stdout,"%s",value);
4332 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4337 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4344 if (LocaleCompare((const char *) tag, "profile") == 0)
4346 if (msl_info->image[n] == (Image *) NULL)
4348 ThrowMSLException(OptionError,"NoImagesDefined",
4349 (const char *) tag);
4352 if (attributes == (const xmlChar **) NULL)
4354 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4368 keyword=(const char *) attributes[i++];
4369 attribute=InterpretImageProperties(msl_info->image_info[n],
4370 msl_info->attributes[n],(const char *) attributes[i],
4372 CloneString(&value,attribute);
4373 if (*keyword == '+')
4376 Remove a profile from the image.
4378 (void) ProfileImage(msl_info->image[n],keyword,
4379 (const unsigned char *) NULL,0,&exception);
4383 Associate a profile with the image.
4385 profile_info=CloneImageInfo(msl_info->image_info[n]);
4386 profile=GetImageProfile(msl_info->image[n],"iptc");
4387 if (profile != (StringInfo *) NULL)
4388 profile_info->profile=(void *) CloneStringInfo(profile);
4389 profile_image=GetImageCache(profile_info,keyword,&exception);
4390 profile_info=DestroyImageInfo(profile_info);
4391 if (profile_image == (Image *) NULL)
4394 name[MaxTextExtent],
4395 filename[MaxTextExtent];
4403 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4404 (void) CopyMagickString(name,keyword,MaxTextExtent);
4405 for (p=filename; *p != '\0'; p++)
4406 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4407 (IsPathAccessible(keyword) == MagickFalse))
4413 Look for profile name (e.g. name:profile).
4415 (void) CopyMagickString(name,filename,(size_t)
4417 for (q=filename; *q != '\0'; q++)
4421 profile=FileToStringInfo(filename,~0UL,&exception);
4422 if (profile != (StringInfo *) NULL)
4424 (void) ProfileImage(msl_info->image[n],name,
4425 GetStringInfoDatum(profile),(size_t)
4426 GetStringInfoLength(profile),&exception);
4427 profile=DestroyStringInfo(profile);
4431 ResetImageProfileIterator(profile_image);
4432 name=GetNextImageProfile(profile_image);
4433 while (name != (const char *) NULL)
4435 profile=GetImageProfile(profile_image,name);
4436 if (profile != (StringInfo *) NULL)
4437 (void) ProfileImage(msl_info->image[n],name,
4438 GetStringInfoDatum(profile),(size_t)
4439 GetStringInfoLength(profile),&exception);
4440 name=GetNextImageProfile(profile_image);
4442 profile_image=DestroyImage(profile_image);
4446 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4451 if (LocaleCompare((const char *) tag,"quantize") == 0)
4459 if (msl_info->image[n] == (Image *) NULL)
4461 ThrowMSLException(OptionError,"NoImagesDefined",
4462 (const char *) tag);
4465 GetQuantizeInfo(&quantize_info);
4466 if (attributes != (const xmlChar **) NULL)
4467 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4469 keyword=(const char *) attributes[i++];
4470 attribute=InterpretImageProperties(msl_info->image_info[n],
4471 msl_info->attributes[n],(const char *) attributes[i],
4473 CloneString(&value,attribute);
4479 if (LocaleCompare(keyword,"colors") == 0)
4481 quantize_info.number_colors=StringToLong(value);
4484 if (LocaleCompare(keyword,"colorspace") == 0)
4486 option=ParseCommandOption(MagickColorspaceOptions,
4489 ThrowMSLException(OptionError,
4490 "UnrecognizedColorspaceType",value);
4491 quantize_info.colorspace=(ColorspaceType) option;
4494 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4501 if (LocaleCompare(keyword,"dither") == 0)
4503 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4506 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4508 quantize_info.dither=(MagickBooleanType) option;
4511 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4518 if (LocaleCompare(keyword,"measure") == 0)
4520 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4523 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4525 quantize_info.measure_error=(MagickBooleanType) option;
4528 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4535 if (LocaleCompare(keyword,"treedepth") == 0)
4537 quantize_info.tree_depth=StringToLong(value);
4540 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4546 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4552 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4555 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4558 text[MaxTextExtent];
4569 draw_info=CloneDrawInfo(msl_info->image_info[n],
4570 msl_info->draw_info[n]);
4572 current=draw_info->affine;
4573 GetAffineMatrix(&affine);
4574 if (attributes != (const xmlChar **) NULL)
4575 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4577 keyword=(const char *) attributes[i++];
4578 attribute=InterpretImageProperties(msl_info->image_info[n],
4579 msl_info->attributes[n],(const char *) attributes[i],
4581 CloneString(&value,attribute);
4587 if (LocaleCompare(keyword,"affine") == 0)
4593 draw_info->affine.sx=StringToDouble(p,&p);
4596 draw_info->affine.rx=StringToDouble(p,&p);
4599 draw_info->affine.ry=StringToDouble(p,&p);
4602 draw_info->affine.sy=StringToDouble(p,&p);
4605 draw_info->affine.tx=StringToDouble(p,&p);
4608 draw_info->affine.ty=StringToDouble(p,&p);
4611 if (LocaleCompare(keyword,"align") == 0)
4613 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4616 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4618 draw_info->align=(AlignType) option;
4621 if (LocaleCompare(keyword,"antialias") == 0)
4623 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4626 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4628 draw_info->stroke_antialias=(MagickBooleanType) option;
4629 draw_info->text_antialias=(MagickBooleanType) option;
4632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4639 if (LocaleCompare(keyword,"density") == 0)
4641 CloneString(&draw_info->density,value);
4644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4651 if (LocaleCompare(keyword,"encoding") == 0)
4653 CloneString(&draw_info->encoding,value);
4656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4663 if (LocaleCompare(keyword, "fill") == 0)
4665 (void) QueryColorCompliance(value,AllCompliance,
4666 &draw_info->fill,&exception);
4669 if (LocaleCompare(keyword,"family") == 0)
4671 CloneString(&draw_info->family,value);
4674 if (LocaleCompare(keyword,"font") == 0)
4676 CloneString(&draw_info->font,value);
4679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4686 if (LocaleCompare(keyword,"geometry") == 0)
4688 flags=ParsePageGeometry(msl_info->image[n],value,
4689 &geometry,&exception);
4690 if ((flags & HeightValue) == 0)
4691 geometry.height=geometry.width;
4694 if (LocaleCompare(keyword,"gravity") == 0)
4696 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4699 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4701 draw_info->gravity=(GravityType) option;
4704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4711 if (LocaleCompare(keyword,"pointsize") == 0)
4713 draw_info->pointsize=StringToDouble(value,
4717 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4724 if (LocaleCompare(keyword,"rotate") == 0)
4726 angle=StringToDouble(value,(char **) NULL);
4727 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4728 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4729 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4730 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4733 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4740 if (LocaleCompare(keyword,"scale") == 0)
4742 flags=ParseGeometry(value,&geometry_info);
4743 if ((flags & SigmaValue) == 0)
4744 geometry_info.sigma=1.0;
4745 affine.sx=geometry_info.rho;
4746 affine.sy=geometry_info.sigma;
4749 if (LocaleCompare(keyword,"skewX") == 0)
4751 angle=StringToDouble(value,(char **) NULL);
4752 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4755 if (LocaleCompare(keyword,"skewY") == 0)
4757 angle=StringToDouble(value,(char **) NULL);
4758 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4761 if (LocaleCompare(keyword,"stretch") == 0)
4763 option=ParseCommandOption(MagickStretchOptions,
4766 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4768 draw_info->stretch=(StretchType) option;
4771 if (LocaleCompare(keyword, "stroke") == 0)
4773 (void) QueryColorCompliance(value,AllCompliance,
4774 &draw_info->stroke,&exception);
4777 if (LocaleCompare(keyword,"strokewidth") == 0)
4779 draw_info->stroke_width=StringToLong(value);
4782 if (LocaleCompare(keyword,"style") == 0)
4784 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4787 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4789 draw_info->style=(StyleType) option;
4792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4799 if (LocaleCompare(keyword,"text") == 0)
4801 CloneString(&draw_info->text,value);
4804 if (LocaleCompare(keyword,"translate") == 0)
4806 flags=ParseGeometry(value,&geometry_info);
4807 if ((flags & SigmaValue) == 0)
4808 geometry_info.sigma=1.0;
4809 affine.tx=geometry_info.rho;
4810 affine.ty=geometry_info.sigma;
4813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4820 if (LocaleCompare(keyword, "undercolor") == 0)
4822 (void) QueryColorCompliance(value,AllCompliance,
4823 &draw_info->undercolor,&exception);
4826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4833 if (LocaleCompare(keyword,"weight") == 0)
4835 draw_info->weight=StringToLong(value);
4838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4845 if (LocaleCompare(keyword,"x") == 0)
4847 geometry.x=StringToLong(value);
4850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4857 if (LocaleCompare(keyword,"y") == 0)
4859 geometry.y=StringToLong(value);
4862 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4874 (void) FormatLocaleString(text,MaxTextExtent,
4875 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4876 geometry.height,(double) geometry.x,(double) geometry.y);
4877 CloneString(&draw_info->geometry,text);
4878 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4879 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4880 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4881 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4882 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4884 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4886 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4887 msl_info->exception);
4888 if (status != MagickFalse)
4893 image=msl_info->attributes[n];
4894 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4895 "%g",metrics.pixels_per_em.x);
4896 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4897 "%g",metrics.pixels_per_em.y);
4898 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4900 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4902 FormatImageProperty(image,"msl:font-metrics.width","%g",
4904 FormatImageProperty(image,"msl:font-metrics.height","%g",
4906 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4907 metrics.max_advance);
4908 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4910 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4912 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4914 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4916 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4918 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4921 draw_info=DestroyDrawInfo(draw_info);
4924 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4929 if (LocaleCompare((const char *) tag,"raise") == 0)
4937 if (msl_info->image[n] == (Image *) NULL)
4939 ThrowMSLException(OptionError,"NoImagesDefined",
4940 (const char *) tag);
4944 SetGeometry(msl_info->image[n],&geometry);
4945 if (attributes != (const xmlChar **) NULL)
4946 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4948 keyword=(const char *) attributes[i++];
4949 attribute=InterpretImageProperties(msl_info->image_info[n],
4950 msl_info->attributes[n],(const char *) attributes[i],
4952 CloneString(&value,attribute);
4958 if (LocaleCompare(keyword,"geometry") == 0)
4960 flags=ParsePageGeometry(msl_info->image[n],value,
4961 &geometry,&exception);
4962 if ((flags & HeightValue) == 0)
4963 geometry.height=geometry.width;
4966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4973 if (LocaleCompare(keyword,"height") == 0)
4975 geometry.height=StringToLong(value);
4978 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4985 if (LocaleCompare(keyword,"raise") == 0)
4987 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4990 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4992 raise=(MagickBooleanType) option;
4995 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5002 if (LocaleCompare(keyword,"width") == 0)
5004 geometry.width=StringToLong(value);
5007 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5019 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5020 msl_info->exception);
5023 if (LocaleCompare((const char *) tag,"read") == 0)
5025 if (attributes == (const xmlChar **) NULL)
5027 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5029 keyword=(const char *) attributes[i++];
5030 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5031 msl_info->attributes[n],(const char *) attributes[i],&exception));
5037 if (LocaleCompare(keyword,"filename") == 0)
5042 (void) CopyMagickString(msl_info->image_info[n]->filename,
5043 value,MaxTextExtent);
5044 image=ReadImage(msl_info->image_info[n],&exception);
5045 CatchException(&exception);
5046 if (image == (Image *) NULL)
5048 AppendImageToList(&msl_info->image[n],image);
5051 (void) SetMSLAttributes(msl_info,keyword,value);
5056 (void) SetMSLAttributes(msl_info,keyword,value);
5063 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5071 if (msl_info->image[n] == (Image *) NULL)
5073 ThrowMSLException(OptionError,"NoImagesDefined",
5074 (const char *) tag);
5077 if (attributes != (const xmlChar **) NULL)
5078 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5080 keyword=(const char *) attributes[i++];
5081 attribute=InterpretImageProperties(msl_info->image_info[n],
5082 msl_info->attributes[n],(const char *) attributes[i],
5084 CloneString(&value,attribute);
5090 if (LocaleCompare(keyword,"geometry") == 0)
5092 flags=ParseGeometry(value,&geometry_info);
5093 if ((flags & SigmaValue) == 0)
5094 geometry_info.sigma=1.0;
5097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5104 if (LocaleCompare(keyword,"radius") == 0)
5106 geometry_info.rho=StringToDouble(value,
5110 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5116 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5122 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5123 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5124 msl_info->exception);
5125 if (paint_image == (Image *) NULL)
5127 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5128 msl_info->image[n]=paint_image;
5131 else if (LocaleCompare((const char *) tag,"repage") == 0)
5133 /* init the values */
5134 width=msl_info->image[n]->page.width;
5135 height=msl_info->image[n]->page.height;
5136 x=msl_info->image[n]->page.x;
5137 y=msl_info->image[n]->page.y;
5139 if (msl_info->image[n] == (Image *) NULL)
5141 ThrowMSLException(OptionError,"NoImagesDefined",
5142 (const char *) tag);
5145 if (attributes == (const xmlChar **) NULL)
5147 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5149 keyword=(const char *) attributes[i++];
5150 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5151 msl_info->attributes[n],(const char *) attributes[i],&exception));
5157 if (LocaleCompare(keyword,"geometry") == 0)
5165 flags=ParseAbsoluteGeometry(value,&geometry);
5166 if ((flags & WidthValue) != 0)
5168 if ((flags & HeightValue) == 0)
5169 geometry.height=geometry.width;
5170 width=geometry.width;
5171 height=geometry.height;
5173 if ((flags & AspectValue) != 0)
5175 if ((flags & XValue) != 0)
5177 if ((flags & YValue) != 0)
5182 if ((flags & XValue) != 0)
5185 if ((width == 0) && (geometry.x > 0))
5186 width=msl_info->image[n]->columns+geometry.x;
5188 if ((flags & YValue) != 0)
5191 if ((height == 0) && (geometry.y > 0))
5192 height=msl_info->image[n]->rows+geometry.y;
5197 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5203 if (LocaleCompare(keyword,"height") == 0)
5205 height = StringToLong( value );
5208 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5214 if (LocaleCompare(keyword,"width") == 0)
5216 width = StringToLong( value );
5219 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5225 if (LocaleCompare(keyword,"x") == 0)
5227 x = StringToLong( value );
5230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5236 if (LocaleCompare(keyword,"y") == 0)
5238 y = StringToLong( value );
5241 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5246 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5252 msl_info->image[n]->page.width=width;
5253 msl_info->image[n]->page.height=height;
5254 msl_info->image[n]->page.x=x;
5255 msl_info->image[n]->page.y=y;
5258 else if (LocaleCompare((const char *) tag,"resample") == 0)
5264 if (msl_info->image[n] == (Image *) NULL)
5266 ThrowMSLException(OptionError,"NoImagesDefined",
5267 (const char *) tag);
5270 if (attributes == (const xmlChar **) NULL)
5272 x_resolution=DefaultResolution;
5273 y_resolution=DefaultResolution;
5274 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5276 keyword=(const char *) attributes[i++];
5277 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5278 msl_info->attributes[n],(const char *) attributes[i],&exception));
5283 if (LocaleCompare(keyword,"blur") == 0)
5285 msl_info->image[n]->blur=StringToDouble(value,
5289 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5295 if (LocaleCompare(keyword,"geometry") == 0)
5300 flags=ParseGeometry(value,&geometry_info);
5301 if ((flags & SigmaValue) == 0)
5302 geometry_info.sigma*=geometry_info.rho;
5303 x_resolution=geometry_info.rho;
5304 y_resolution=geometry_info.sigma;
5307 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5313 if (LocaleCompare(keyword,"x-resolution") == 0)
5315 x_resolution=StringToDouble(value,(char **) NULL);
5318 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5324 if (LocaleCompare(keyword,"y-resolution") == 0)
5326 y_resolution=StringToDouble(value,(char **) NULL);
5329 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5334 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5350 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5352 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5353 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5354 msl_info->image[n]->resolution.x))+0.5);
5355 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5356 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5357 msl_info->image[n]->resolution.y))+0.5);
5358 resample_image=ResizeImage(msl_info->image[n],width,height,
5359 msl_info->image[n]->filter,msl_info->image[n]->blur,
5360 msl_info->exception);
5361 if (resample_image == (Image *) NULL)
5363 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5364 msl_info->image[n]=resample_image;
5368 if (LocaleCompare((const char *) tag,"resize") == 0)
5382 if (msl_info->image[n] == (Image *) NULL)
5384 ThrowMSLException(OptionError,"NoImagesDefined",
5385 (const char *) tag);
5388 filter=UndefinedFilter;
5390 if (attributes != (const xmlChar **) NULL)
5391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5393 keyword=(const char *) attributes[i++];
5394 attribute=InterpretImageProperties(msl_info->image_info[n],
5395 msl_info->attributes[n],(const char *) attributes[i],
5397 CloneString(&value,attribute);
5403 if (LocaleCompare(keyword,"filter") == 0)
5405 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5408 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5410 filter=(FilterTypes) option;
5413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5420 if (LocaleCompare(keyword,"geometry") == 0)
5422 flags=ParseRegionGeometry(msl_info->image[n],value,
5423 &geometry,&exception);
5426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5433 if (LocaleCompare(keyword,"height") == 0)
5435 geometry.height=StringToUnsignedLong(value);
5438 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5445 if (LocaleCompare(keyword,"support") == 0)
5447 blur=StringToDouble(value,(char **) NULL);
5450 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5457 if (LocaleCompare(keyword,"width") == 0)
5459 geometry.width=StringToLong(value);
5462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5474 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5475 geometry.height,filter,blur,msl_info->exception);
5476 if (resize_image == (Image *) NULL)
5478 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5479 msl_info->image[n]=resize_image;
5482 if (LocaleCompare((const char *) tag,"roll") == 0)
5490 if (msl_info->image[n] == (Image *) NULL)
5492 ThrowMSLException(OptionError,"NoImagesDefined",
5493 (const char *) tag);
5496 SetGeometry(msl_info->image[n],&geometry);
5497 if (attributes != (const xmlChar **) NULL)
5498 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5500 keyword=(const char *) attributes[i++];
5501 attribute=InterpretImageProperties(msl_info->image_info[n],
5502 msl_info->attributes[n],(const char *) attributes[i],
5504 CloneString(&value,attribute);
5510 if (LocaleCompare(keyword,"geometry") == 0)
5512 flags=ParsePageGeometry(msl_info->image[n],value,
5513 &geometry,&exception);
5514 if ((flags & HeightValue) == 0)
5515 geometry.height=geometry.width;
5518 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5525 if (LocaleCompare(keyword,"x") == 0)
5527 geometry.x=StringToLong(value);
5530 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5537 if (LocaleCompare(keyword,"y") == 0)
5539 geometry.y=StringToLong(value);
5542 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5554 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5555 msl_info->exception);
5556 if (roll_image == (Image *) NULL)
5558 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5559 msl_info->image[n]=roll_image;
5562 else if (LocaleCompare((const char *) tag,"roll") == 0)
5564 /* init the values */
5565 width=msl_info->image[n]->columns;
5566 height=msl_info->image[n]->rows;
5569 if (msl_info->image[n] == (Image *) NULL)
5571 ThrowMSLException(OptionError,"NoImagesDefined",
5572 (const char *) tag);
5575 if (attributes == (const xmlChar **) NULL)
5577 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5579 keyword=(const char *) attributes[i++];
5580 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5581 msl_info->attributes[n],(const char *) attributes[i],&exception));
5587 if (LocaleCompare(keyword,"geometry") == 0)
5589 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5592 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5598 if (LocaleCompare(keyword,"x") == 0)
5600 x = StringToLong( value );
5603 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5609 if (LocaleCompare(keyword,"y") == 0)
5611 y = StringToLong( value );
5614 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5619 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5632 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5633 if (newImage == (Image *) NULL)
5635 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5636 msl_info->image[n]=newImage;
5641 if (LocaleCompare((const char *) tag,"rotate") == 0)
5649 if (msl_info->image[n] == (Image *) NULL)
5651 ThrowMSLException(OptionError,"NoImagesDefined",
5652 (const char *) tag);
5655 if (attributes != (const xmlChar **) NULL)
5656 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5658 keyword=(const char *) attributes[i++];
5659 attribute=InterpretImageProperties(msl_info->image_info[n],
5660 msl_info->attributes[n],(const char *) attributes[i],
5662 CloneString(&value,attribute);
5668 if (LocaleCompare(keyword,"degrees") == 0)
5670 geometry_info.rho=StringToDouble(value,
5674 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5681 if (LocaleCompare(keyword,"geometry") == 0)
5683 flags=ParseGeometry(value,&geometry_info);
5684 if ((flags & SigmaValue) == 0)
5685 geometry_info.sigma=1.0;
5688 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5700 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5701 msl_info->exception);
5702 if (rotate_image == (Image *) NULL)
5704 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5705 msl_info->image[n]=rotate_image;
5708 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5710 /* init the values */
5713 if (msl_info->image[n] == (Image *) NULL)
5715 ThrowMSLException(OptionError,"NoImagesDefined",
5716 (const char *) tag);
5719 if (attributes == (const xmlChar **) NULL)
5721 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5723 keyword=(const char *) attributes[i++];
5724 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5725 msl_info->attributes[n],(const char *) attributes[i],&exception));
5731 if (LocaleCompare(keyword,"degrees") == 0)
5733 degrees = StringToDouble(value,(char **) NULL);
5736 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5741 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5754 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5755 if (newImage == (Image *) NULL)
5757 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5758 msl_info->image[n]=newImage;
5763 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5768 if (LocaleCompare((const char *) tag,"sample") == 0)
5776 if (msl_info->image[n] == (Image *) NULL)
5778 ThrowMSLException(OptionError,"NoImagesDefined",
5779 (const char *) tag);
5782 if (attributes != (const xmlChar **) NULL)
5783 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5785 keyword=(const char *) attributes[i++];
5786 attribute=InterpretImageProperties(msl_info->image_info[n],
5787 msl_info->attributes[n],(const char *) attributes[i],
5789 CloneString(&value,attribute);
5795 if (LocaleCompare(keyword,"geometry") == 0)
5797 flags=ParseRegionGeometry(msl_info->image[n],value,
5798 &geometry,&exception);
5801 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5808 if (LocaleCompare(keyword,"height") == 0)
5810 geometry.height=StringToUnsignedLong(value);
5813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5820 if (LocaleCompare(keyword,"width") == 0)
5822 geometry.width=StringToLong(value);
5825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5831 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5837 sample_image=SampleImage(msl_info->image[n],geometry.width,
5838 geometry.height,msl_info->exception);
5839 if (sample_image == (Image *) NULL)
5841 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5842 msl_info->image[n]=sample_image;
5845 if (LocaleCompare((const char *) tag,"scale") == 0)
5853 if (msl_info->image[n] == (Image *) NULL)
5855 ThrowMSLException(OptionError,"NoImagesDefined",
5856 (const char *) tag);
5859 if (attributes != (const xmlChar **) NULL)
5860 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5862 keyword=(const char *) attributes[i++];
5863 attribute=InterpretImageProperties(msl_info->image_info[n],
5864 msl_info->attributes[n],(const char *) attributes[i],
5866 CloneString(&value,attribute);
5872 if (LocaleCompare(keyword,"geometry") == 0)
5874 flags=ParseRegionGeometry(msl_info->image[n],value,
5875 &geometry,&exception);
5878 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5885 if (LocaleCompare(keyword,"height") == 0)
5887 geometry.height=StringToUnsignedLong(value);
5890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5897 if (LocaleCompare(keyword,"width") == 0)
5899 geometry.width=StringToLong(value);
5902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5914 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5915 geometry.height,msl_info->exception);
5916 if (scale_image == (Image *) NULL)
5918 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5919 msl_info->image[n]=scale_image;
5922 if (LocaleCompare((const char *) tag,"segment") == 0)
5933 if (msl_info->image[n] == (Image *) NULL)
5935 ThrowMSLException(OptionError,"NoImagesDefined",
5936 (const char *) tag);
5939 geometry_info.rho=1.0;
5940 geometry_info.sigma=1.5;
5941 colorspace=RGBColorspace;
5942 verbose=MagickFalse;
5943 if (attributes != (const xmlChar **) NULL)
5944 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5946 keyword=(const char *) attributes[i++];
5947 attribute=InterpretImageProperties(msl_info->image_info[n],
5948 msl_info->attributes[n],(const char *) attributes[i],
5950 CloneString(&value,attribute);
5956 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5958 geometry_info.rho=StringToDouble(value,
5962 if (LocaleCompare(keyword,"colorspace") == 0)
5964 option=ParseCommandOption(MagickColorspaceOptions,
5967 ThrowMSLException(OptionError,
5968 "UnrecognizedColorspaceType",value);
5969 colorspace=(ColorspaceType) option;
5972 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5979 if (LocaleCompare(keyword,"geometry") == 0)
5981 flags=ParseGeometry(value,&geometry_info);
5982 if ((flags & SigmaValue) == 0)
5983 geometry_info.sigma=1.5;
5986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5993 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5995 geometry_info.sigma=StringToDouble(value,
5999 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6011 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
6012 geometry_info.rho,geometry_info.sigma,&exception);
6015 else if (LocaleCompare((const char *) tag, "set") == 0)
6017 if (msl_info->image[n] == (Image *) NULL)
6019 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6023 if (attributes == (const xmlChar **) NULL)
6025 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6027 keyword=(const char *) attributes[i++];
6028 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6029 msl_info->attributes[n],(const char *) attributes[i],&exception));
6035 if (LocaleCompare(keyword,"clip-mask") == 0)
6037 for (j=0; j < msl_info->n; j++)
6042 property=GetImageProperty(msl_info->attributes[j],"id",
6044 if (LocaleCompare(property,value) == 0)
6046 SetImageMask(msl_info->image[n],msl_info->image[j],
6053 if (LocaleCompare(keyword,"clip-path") == 0)
6055 for (j=0; j < msl_info->n; j++)
6060 property=GetImageProperty(msl_info->attributes[j],"id",
6062 if (LocaleCompare(property,value) == 0)
6064 SetImageClipMask(msl_info->image[n],msl_info->image[j],
6071 if (LocaleCompare(keyword,"colorspace") == 0)
6076 colorspace=(ColorspaceType) ParseCommandOption(
6077 MagickColorspaceOptions,MagickFalse,value);
6079 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6081 (void) TransformImageColorspace(msl_info->image[n],
6082 (ColorspaceType) colorspace,&exception);
6085 (void) SetMSLAttributes(msl_info,keyword,value);
6086 (void) SetImageProperty(msl_info->image[n],keyword,value,
6093 if (LocaleCompare(keyword,"density") == 0)
6095 flags=ParseGeometry(value,&geometry_info);
6096 msl_info->image[n]->resolution.x=geometry_info.rho;
6097 msl_info->image[n]->resolution.y=geometry_info.sigma;
6098 if ((flags & SigmaValue) == 0)
6099 msl_info->image[n]->resolution.y=
6100 msl_info->image[n]->resolution.x;
6103 (void) SetMSLAttributes(msl_info,keyword,value);
6104 (void) SetImageProperty(msl_info->image[n],keyword,value,
6111 if (LocaleCompare(keyword, "opacity") == 0)
6113 ssize_t opac = OpaqueAlpha,
6114 len = (ssize_t) strlen( value );
6116 if (value[len-1] == '%') {
6118 (void) CopyMagickString(tmp,value,len);
6119 opac = StringToLong( tmp );
6120 opac = (int)(QuantumRange * ((float)opac/100));
6122 opac = StringToLong( value );
6123 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6127 (void) SetMSLAttributes(msl_info,keyword,value);
6128 (void) SetImageProperty(msl_info->image[n],keyword,value,
6129 msl_info->exception);
6135 if (LocaleCompare(keyword, "page") == 0)
6138 page[MaxTextExtent];
6149 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6150 image_option=GetImageOption(msl_info->image_info[n],"page");
6151 if (image_option != (const char *) NULL)
6152 flags=ParseAbsoluteGeometry(image_option,&geometry);
6153 flags=ParseAbsoluteGeometry(value,&geometry);
6154 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6155 (double) geometry.width,(double) geometry.height);
6156 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6157 (void) FormatLocaleString(page,MaxTextExtent,
6158 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6159 (double) geometry.height,(double) geometry.x,(double)
6161 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6162 msl_info->image_info[n]->page=GetPageGeometry(page);
6165 (void) SetMSLAttributes(msl_info,keyword,value);
6166 (void) SetImageProperty(msl_info->image[n],keyword,value,
6167 msl_info->exception);
6172 (void) SetMSLAttributes(msl_info,keyword,value);
6173 (void) SetImageProperty(msl_info->image[n],keyword,value,
6174 msl_info->exception);
6181 if (LocaleCompare((const char *) tag,"shade") == 0)
6192 if (msl_info->image[n] == (Image *) NULL)
6194 ThrowMSLException(OptionError,"NoImagesDefined",
6195 (const char *) tag);
6199 if (attributes != (const xmlChar **) NULL)
6200 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6202 keyword=(const char *) attributes[i++];
6203 attribute=InterpretImageProperties(msl_info->image_info[n],
6204 msl_info->attributes[n],(const char *) attributes[i],
6206 CloneString(&value,attribute);
6212 if (LocaleCompare(keyword,"azimuth") == 0)
6214 geometry_info.rho=StringToDouble(value,
6218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6225 if (LocaleCompare(keyword,"elevation") == 0)
6227 geometry_info.sigma=StringToDouble(value,
6231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6238 if (LocaleCompare(keyword,"geometry") == 0)
6240 flags=ParseGeometry(value,&geometry_info);
6241 if ((flags & SigmaValue) == 0)
6242 geometry_info.sigma=1.0;
6245 if (LocaleCompare(keyword,"gray") == 0)
6247 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6250 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6252 gray=(MagickBooleanType) option;
6255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6267 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6268 geometry_info.sigma,msl_info->exception);
6269 if (shade_image == (Image *) NULL)
6271 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6272 msl_info->image[n]=shade_image;
6275 if (LocaleCompare((const char *) tag,"shadow") == 0)
6283 if (msl_info->image[n] == (Image *) NULL)
6285 ThrowMSLException(OptionError,"NoImagesDefined",
6286 (const char *) tag);
6289 if (attributes != (const xmlChar **) NULL)
6290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6292 keyword=(const char *) attributes[i++];
6293 attribute=InterpretImageProperties(msl_info->image_info[n],
6294 msl_info->attributes[n],(const char *) attributes[i],
6296 CloneString(&value,attribute);
6302 if (LocaleCompare(keyword,"geometry") == 0)
6304 flags=ParseGeometry(value,&geometry_info);
6305 if ((flags & SigmaValue) == 0)
6306 geometry_info.sigma=1.0;
6309 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6316 if (LocaleCompare(keyword,"opacity") == 0)
6318 geometry_info.rho=StringToLong(value);
6321 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6328 if (LocaleCompare(keyword,"sigma") == 0)
6330 geometry_info.sigma=StringToLong(value);
6338 if (LocaleCompare(keyword,"x") == 0)
6340 geometry_info.xi=StringToDouble(value,
6344 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6351 if (LocaleCompare(keyword,"y") == 0)
6353 geometry_info.psi=StringToLong(value);
6356 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6362 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6368 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6369 geometry_info.sigma,0.0,(ssize_t) ceil(geometry_info.xi-0.5),
6370 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6371 if (shadow_image == (Image *) NULL)
6373 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6374 msl_info->image[n]=shadow_image;
6377 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6383 if (msl_info->image[n] == (Image *) NULL)
6385 ThrowMSLException(OptionError,"NoImagesDefined",
6386 (const char *) tag);
6390 NOTE: sharpen can have no attributes, since we use all the defaults!
6392 if (attributes != (const xmlChar **) NULL)
6394 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6396 keyword=(const char *) attributes[i++];
6397 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6398 msl_info->attributes[n],(const char *) attributes[i],&exception));
6404 if (LocaleCompare(keyword, "bias") == 0)
6406 bias = StringToDouble(value,(char **) NULL);
6409 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6415 if (LocaleCompare(keyword, "radius") == 0)
6417 radius = StringToDouble(value,(char **) NULL);
6420 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6426 if (LocaleCompare(keyword,"sigma") == 0)
6428 sigma = StringToLong( value );
6431 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6436 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6450 newImage=SharpenImage(msl_info->image[n],radius,sigma,bias,
6451 msl_info->exception);
6452 if (newImage == (Image *) NULL)
6454 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6455 msl_info->image[n]=newImage;
6459 else if (LocaleCompare((const char *) tag,"shave") == 0)
6461 /* init the values */
6465 if (msl_info->image[n] == (Image *) NULL)
6467 ThrowMSLException(OptionError,"NoImagesDefined",
6468 (const char *) tag);
6471 if (attributes == (const xmlChar **) NULL)
6473 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6475 keyword=(const char *) attributes[i++];
6476 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6477 msl_info->attributes[n],(const char *) attributes[i],&exception));
6483 if (LocaleCompare(keyword,"geometry") == 0)
6485 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6488 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6494 if (LocaleCompare(keyword,"height") == 0)
6496 height = StringToLong( value );
6499 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6505 if (LocaleCompare(keyword,"width") == 0)
6507 width = StringToLong( value );
6510 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6515 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6530 rectInfo.height = height;
6531 rectInfo.width = width;
6536 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6537 msl_info->exception);
6538 if (newImage == (Image *) NULL)
6540 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6541 msl_info->image[n]=newImage;
6546 if (LocaleCompare((const char *) tag,"shear") == 0)
6554 if (msl_info->image[n] == (Image *) NULL)
6556 ThrowMSLException(OptionError,"NoImagesDefined",
6557 (const char *) tag);
6560 if (attributes != (const xmlChar **) NULL)
6561 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6563 keyword=(const char *) attributes[i++];
6564 attribute=InterpretImageProperties(msl_info->image_info[n],
6565 msl_info->attributes[n],(const char *) attributes[i],
6567 CloneString(&value,attribute);
6573 if (LocaleCompare(keyword, "fill") == 0)
6575 (void) QueryColorCompliance(value,AllCompliance,
6576 &msl_info->image[n]->background_color,&exception);
6579 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6586 if (LocaleCompare(keyword,"geometry") == 0)
6588 flags=ParseGeometry(value,&geometry_info);
6589 if ((flags & SigmaValue) == 0)
6590 geometry_info.sigma=1.0;
6593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6600 if (LocaleCompare(keyword,"x") == 0)
6602 geometry_info.rho=StringToDouble(value,
6606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6613 if (LocaleCompare(keyword,"y") == 0)
6615 geometry_info.sigma=StringToLong(value);
6618 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6624 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6630 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6631 geometry_info.sigma,msl_info->exception);
6632 if (shear_image == (Image *) NULL)
6634 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6635 msl_info->image[n]=shear_image;
6638 if (LocaleCompare((const char *) tag,"signature") == 0)
6643 if (msl_info->image[n] == (Image *) NULL)
6645 ThrowMSLException(OptionError,"NoImagesDefined",
6646 (const char *) tag);
6649 if (attributes != (const xmlChar **) NULL)
6650 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6652 keyword=(const char *) attributes[i++];
6653 attribute=InterpretImageProperties(msl_info->image_info[n],
6654 msl_info->attributes[n],(const char *) attributes[i],
6656 CloneString(&value,attribute);
6661 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6667 (void) SignatureImage(msl_info->image[n],&exception);
6670 if (LocaleCompare((const char *) tag,"solarize") == 0)
6675 if (msl_info->image[n] == (Image *) NULL)
6677 ThrowMSLException(OptionError,"NoImagesDefined",
6678 (const char *) tag);
6681 geometry_info.rho=QuantumRange/2.0;
6682 if (attributes != (const xmlChar **) NULL)
6683 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6685 keyword=(const char *) attributes[i++];
6686 attribute=InterpretImageProperties(msl_info->image_info[n],
6687 msl_info->attributes[n],(const char *) attributes[i],
6689 CloneString(&value,attribute);
6695 if (LocaleCompare(keyword,"geometry") == 0)
6697 flags=ParseGeometry(value,&geometry_info);
6700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6707 if (LocaleCompare(keyword,"threshold") == 0)
6709 geometry_info.rho=StringToDouble(value,
6713 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6725 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6726 msl_info->exception);
6729 if (LocaleCompare((const char *) tag,"spread") == 0)
6737 if (msl_info->image[n] == (Image *) NULL)
6739 ThrowMSLException(OptionError,"NoImagesDefined",
6740 (const char *) tag);
6743 if (attributes != (const xmlChar **) NULL)
6744 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6746 keyword=(const char *) attributes[i++];
6747 attribute=InterpretImageProperties(msl_info->image_info[n],
6748 msl_info->attributes[n],(const char *) attributes[i],
6750 CloneString(&value,attribute);
6756 if (LocaleCompare(keyword,"geometry") == 0)
6758 flags=ParseGeometry(value,&geometry_info);
6759 if ((flags & SigmaValue) == 0)
6760 geometry_info.sigma=1.0;
6763 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6770 if (LocaleCompare(keyword,"radius") == 0)
6772 geometry_info.rho=StringToDouble(value,
6776 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6782 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6788 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6789 msl_info->image[n]->interpolate,msl_info->exception);
6790 if (spread_image == (Image *) NULL)
6792 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6793 msl_info->image[n]=spread_image;
6796 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6799 watermark = (Image*)NULL;
6801 if (msl_info->image[n] == (Image *) NULL)
6803 ThrowMSLException(OptionError,"NoImagesDefined",
6804 (const char *) tag);
6807 if (attributes == (const xmlChar **) NULL)
6809 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6811 keyword=(const char *) attributes[i++];
6812 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6813 msl_info->attributes[n],(const char *) attributes[i],&exception));
6819 if (LocaleCompare(keyword,"image") == 0)
6821 for (j=0; j<msl_info->n;j++)
6824 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6826 if (theAttr && LocaleCompare(theAttr, value) == 0)
6828 watermark = msl_info->image[j];
6834 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6839 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6848 if ( watermark != (Image*) NULL )
6853 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6854 if (newImage == (Image *) NULL)
6856 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6857 msl_info->image[n]=newImage;
6860 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6862 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6865 stereoImage = (Image*)NULL;
6867 if (msl_info->image[n] == (Image *) NULL)
6869 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6872 if (attributes == (const xmlChar **) NULL)
6874 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6876 keyword=(const char *) attributes[i++];
6877 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6878 msl_info->attributes[n],(const char *) attributes[i],&exception));
6884 if (LocaleCompare(keyword,"image") == 0)
6886 for (j=0; j<msl_info->n;j++)
6889 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6891 if (theAttr && LocaleCompare(theAttr, value) == 0)
6893 stereoImage = msl_info->image[j];
6899 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6904 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6913 if ( stereoImage != (Image*) NULL )
6918 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6919 if (newImage == (Image *) NULL)
6921 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6922 msl_info->image[n]=newImage;
6925 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6927 if (LocaleCompare((const char *) tag,"swap") == 0)
6938 if (msl_info->image[n] == (Image *) NULL)
6940 ThrowMSLException(OptionError,"NoImagesDefined",
6941 (const char *) tag);
6946 if (attributes != (const xmlChar **) NULL)
6947 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6949 keyword=(const char *) attributes[i++];
6950 attribute=InterpretImageProperties(msl_info->image_info[n],
6951 msl_info->attributes[n],(const char *) attributes[i],
6953 CloneString(&value,attribute);
6959 if (LocaleCompare(keyword,"indexes") == 0)
6961 flags=ParseGeometry(value,&geometry_info);
6962 index=(ssize_t) geometry_info.rho;
6963 if ((flags & SigmaValue) == 0)
6964 swap_index=(ssize_t) geometry_info.sigma;
6967 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6973 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6982 p=GetImageFromList(msl_info->image[n],index);
6983 q=GetImageFromList(msl_info->image[n],swap_index);
6984 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6986 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6989 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6990 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6991 msl_info->exception));
6992 ReplaceImageInList(&q,swap);
6993 msl_info->image[n]=GetFirstImageInList(q);
6996 if (LocaleCompare((const char *) tag,"swirl") == 0)
7004 if (msl_info->image[n] == (Image *) NULL)
7006 ThrowMSLException(OptionError,"NoImagesDefined",
7007 (const char *) tag);
7010 if (attributes != (const xmlChar **) NULL)
7011 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7013 keyword=(const char *) attributes[i++];
7014 attribute=InterpretImageProperties(msl_info->image_info[n],
7015 msl_info->attributes[n],(const char *) attributes[i],
7017 CloneString(&value,attribute);
7023 if (LocaleCompare(keyword,"degrees") == 0)
7025 geometry_info.rho=StringToDouble(value,
7029 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7036 if (LocaleCompare(keyword,"geometry") == 0)
7038 flags=ParseGeometry(value,&geometry_info);
7039 if ((flags & SigmaValue) == 0)
7040 geometry_info.sigma=1.0;
7043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7049 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7055 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7056 msl_info->image[n]->interpolate,msl_info->exception);
7057 if (swirl_image == (Image *) NULL)
7059 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7060 msl_info->image[n]=swirl_image;
7063 if (LocaleCompare((const char *) tag,"sync") == 0)
7068 if (msl_info->image[n] == (Image *) NULL)
7070 ThrowMSLException(OptionError,"NoImagesDefined",
7071 (const char *) tag);
7074 if (attributes != (const xmlChar **) NULL)
7075 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7077 keyword=(const char *) attributes[i++];
7078 attribute=InterpretImageProperties(msl_info->image_info[n],
7079 msl_info->attributes[n],(const char *) attributes[i],
7081 CloneString(&value,attribute);
7086 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7092 (void) SyncImage(msl_info->image[n],&exception);
7095 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7100 if (LocaleCompare((const char *) tag,"map") == 0)
7108 if (msl_info->image[n] == (Image *) NULL)
7110 ThrowMSLException(OptionError,"NoImagesDefined",
7111 (const char *) tag);
7114 texture_image=NewImageList();
7115 if (attributes != (const xmlChar **) NULL)
7116 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7118 keyword=(const char *) attributes[i++];
7119 attribute=InterpretImageProperties(msl_info->image_info[n],
7120 msl_info->attributes[n],(const char *) attributes[i],
7122 CloneString(&value,attribute);
7128 if (LocaleCompare(keyword,"image") == 0)
7129 for (j=0; j < msl_info->n; j++)
7134 attribute=GetImageProperty(msl_info->attributes[j],"id",
7136 if ((attribute != (const char *) NULL) &&
7137 (LocaleCompare(attribute,value) == 0))
7139 texture_image=CloneImage(msl_info->image[j],0,0,
7140 MagickFalse,&exception);
7148 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7154 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7155 texture_image=DestroyImage(texture_image);
7158 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7160 /* init the values */
7161 double threshold = 0;
7163 if (msl_info->image[n] == (Image *) NULL)
7165 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7168 if (attributes == (const xmlChar **) NULL)
7170 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7172 keyword=(const char *) attributes[i++];
7173 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7174 msl_info->attributes[n],(const char *) attributes[i],&exception));
7180 if (LocaleCompare(keyword,"threshold") == 0)
7182 threshold = StringToDouble(value,(char **) NULL);
7185 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7190 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7200 BilevelImage(msl_info->image[n],threshold,&exception);
7204 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7206 if (msl_info->image[n] == (Image *) NULL)
7208 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7211 if (attributes == (const xmlChar **) NULL)
7213 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7215 keyword=(const char *) attributes[i++];
7216 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7217 msl_info->attributes[n],(const char *) attributes[i],&exception));
7223 if (LocaleCompare(keyword,"color") == 0)
7228 (void) QueryColorCompliance(value,AllCompliance,&target,
7230 (void) TransparentPaintImage(msl_info->image[n],&target,
7231 TransparentAlpha,MagickFalse,msl_info->exception);
7234 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7239 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7246 else if (LocaleCompare((const char *) tag, "trim") == 0)
7248 if (msl_info->image[n] == (Image *) NULL)
7250 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7254 /* no attributes here */
7256 /* process the image */
7263 /* all zeros on a crop == trim edges! */
7264 rectInfo.height = rectInfo.width = 0;
7265 rectInfo.x = rectInfo.y = 0;
7267 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7268 if (newImage == (Image *) NULL)
7270 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7271 msl_info->image[n]=newImage;
7275 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7280 if (LocaleCompare((const char *) tag,"write") == 0)
7282 if (msl_info->image[n] == (Image *) NULL)
7284 ThrowMSLException(OptionError,"NoImagesDefined",
7285 (const char *) tag);
7288 if (attributes == (const xmlChar **) NULL)
7290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7292 keyword=(const char *) attributes[i++];
7293 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7294 msl_info->attributes[n],(const char *) attributes[i],&exception));
7300 if (LocaleCompare(keyword,"filename") == 0)
7302 (void) CopyMagickString(msl_info->image[n]->filename,value,
7306 (void) SetMSLAttributes(msl_info,keyword,value);
7310 (void) SetMSLAttributes(msl_info,keyword,value);
7318 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7319 msl_info->exception);
7323 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7327 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7331 if ( value != NULL )
7332 value=DestroyString(value);
7333 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7336 static void MSLEndElement(void *context,const xmlChar *tag)
7345 Called when the end of an element has been detected.
7347 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7349 msl_info=(MSLInfo *) context;
7356 if (LocaleCompare((const char *) tag,"comment") == 0 )
7358 (void) DeleteImageProperty(msl_info->image[n],"comment");
7359 if (msl_info->content == (char *) NULL)
7361 StripString(msl_info->content);
7362 (void) SetImageProperty(msl_info->image[n],"comment",
7363 msl_info->content,msl_info->exception);
7371 if (LocaleCompare((const char *) tag, "group") == 0 )
7373 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7375 ssize_t i = (ssize_t)
7376 (msl_info->group_info[msl_info->number_groups-1].numImages);
7379 if (msl_info->image[msl_info->n] != (Image *) NULL)
7380 msl_info->image[msl_info->n]=DestroyImage(
7381 msl_info->image[msl_info->n]);
7382 msl_info->attributes[msl_info->n]=DestroyImage(
7383 msl_info->attributes[msl_info->n]);
7384 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7385 msl_info->image_info[msl_info->n]);
7389 msl_info->number_groups--;
7396 if (LocaleCompare((const char *) tag, "image") == 0)
7397 MSLPopImage(msl_info);
7403 if (LocaleCompare((const char *) tag,"label") == 0 )
7405 (void) DeleteImageProperty(msl_info->image[n],"label");
7406 if (msl_info->content == (char *) NULL)
7408 StripString(msl_info->content);
7409 (void) SetImageProperty(msl_info->image[n],"label",
7410 msl_info->content,msl_info->exception);
7418 if (LocaleCompare((const char *) tag, "msl") == 0 )
7421 This our base element.
7422 at the moment we don't do anything special
7423 but someday we might!
7431 if (msl_info->content != (char *) NULL)
7432 msl_info->content=DestroyString(msl_info->content);
7435 static void MSLCharacters(void *context,const xmlChar *c,int length)
7447 Receiving some characters from the parser.
7449 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7450 " SAX.characters(%s,%d)",c,length);
7451 msl_info=(MSLInfo *) context;
7452 if (msl_info->content != (char *) NULL)
7453 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7454 strlen(msl_info->content)+length+MaxTextExtent,
7455 sizeof(*msl_info->content));
7458 msl_info->content=(char *) NULL;
7459 if (~length >= (MaxTextExtent-1))
7460 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7461 sizeof(*msl_info->content));
7462 if (msl_info->content != (char *) NULL)
7463 *msl_info->content='\0';
7465 if (msl_info->content == (char *) NULL)
7467 p=msl_info->content+strlen(msl_info->content);
7468 for (i=0; i < length; i++)
7473 static void MSLReference(void *context,const xmlChar *name)
7482 Called when an entity reference is detected.
7484 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7485 " SAX.reference(%s)",name);
7486 msl_info=(MSLInfo *) context;
7487 parser=msl_info->parser;
7489 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7491 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7494 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7500 Receiving some ignorable whitespaces from the parser.
7502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7503 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7504 msl_info=(MSLInfo *) context;
7508 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7509 const xmlChar *data)
7515 A processing instruction has been parsed.
7517 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7518 " SAX.processingInstruction(%s, %s)",
7520 msl_info=(MSLInfo *) context;
7524 static void MSLComment(void *context,const xmlChar *value)
7530 A comment has been parsed.
7532 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7533 " SAX.comment(%s)",value);
7534 msl_info=(MSLInfo *) context;
7538 static void MSLWarning(void *context,const char *format,...)
7542 reason[MaxTextExtent];
7551 Display and format a warning messages, gives file, line, position and
7554 va_start(operands,format);
7555 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7556 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7557 msl_info=(MSLInfo *) context;
7559 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7560 (void) vsprintf(reason,format,operands);
7562 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7564 message=GetExceptionMessage(errno);
7565 ThrowMSLException(CoderError,reason,message);
7566 message=DestroyString(message);
7570 static void MSLError(void *context,const char *format,...)
7573 reason[MaxTextExtent];
7582 Display and format a error formats, gives file, line, position and
7585 va_start(operands,format);
7586 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7587 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7588 msl_info=(MSLInfo *) context;
7590 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7591 (void) vsprintf(reason,format,operands);
7593 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7595 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7599 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7611 Called when a pcdata block has been parsed.
7613 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7614 " SAX.pcdata(%s, %d)",value,length);
7615 msl_info=(MSLInfo *) context;
7617 parser=msl_info->parser;
7618 child=xmlGetLastChild(parser->node);
7619 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7621 xmlTextConcat(child,value,length);
7624 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7627 static void MSLExternalSubset(void *context,const xmlChar *name,
7628 const xmlChar *external_id,const xmlChar *system_id)
7643 Does this document has an external subset?
7645 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7646 " SAX.externalSubset(%s %s %s)",name,
7647 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7648 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7649 msl_info=(MSLInfo *) context;
7651 parser=msl_info->parser;
7652 if (((external_id == NULL) && (system_id == NULL)) ||
7653 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7654 (msl_info->document == 0)))
7656 input=MSLResolveEntity(context,external_id,system_id);
7659 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7660 parser_context=(*parser);
7661 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7662 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7664 parser->errNo=XML_ERR_NO_MEMORY;
7665 parser->input=parser_context.input;
7666 parser->inputNr=parser_context.inputNr;
7667 parser->inputMax=parser_context.inputMax;
7668 parser->inputTab=parser_context.inputTab;
7674 xmlPushInput(parser,input);
7675 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7676 if (input->filename == (char *) NULL)
7677 input->filename=(char *) xmlStrdup(system_id);
7680 input->base=parser->input->cur;
7681 input->cur=parser->input->cur;
7683 xmlParseExternalSubset(parser,external_id,system_id);
7684 while (parser->inputNr > 1)
7685 (void) xmlPopInput(parser);
7686 xmlFreeInputStream(parser->input);
7687 xmlFree(parser->inputTab);
7688 parser->input=parser_context.input;
7689 parser->inputNr=parser_context.inputNr;
7690 parser->inputMax=parser_context.inputMax;
7691 parser->inputTab=parser_context.inputTab;
7694 #if defined(__cplusplus) || defined(c_plusplus)
7698 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7699 ExceptionInfo *exception)
7702 message[MaxTextExtent];
7725 assert(image_info != (const ImageInfo *) NULL);
7726 assert(image_info->signature == MagickSignature);
7727 if (image_info->debug != MagickFalse)
7728 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7729 image_info->filename);
7730 assert(image != (Image **) NULL);
7731 msl_image=AcquireImage(image_info,exception);
7732 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7733 if (status == MagickFalse)
7735 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7736 msl_image->filename);
7737 msl_image=DestroyImageList(msl_image);
7738 return(MagickFalse);
7740 msl_image->columns=1;
7745 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7746 msl_info.exception=exception;
7747 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7748 sizeof(*msl_info.image_info));
7749 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7750 sizeof(*msl_info.draw_info));
7751 /* top of the stack is the MSL file itself */
7752 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7753 msl_info.attributes=(Image **) AcquireMagickMemory(
7754 sizeof(*msl_info.attributes));
7755 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7756 sizeof(*msl_info.group_info));
7757 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7758 (msl_info.image == (Image **) NULL) ||
7759 (msl_info.attributes == (Image **) NULL) ||
7760 (msl_info.group_info == (MSLGroupInfo *) NULL))
7761 ThrowFatalException(ResourceLimitFatalError,
7762 "UnableToInterpretMSLImage");
7763 *msl_info.image_info=CloneImageInfo(image_info);
7764 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7765 *msl_info.attributes=AcquireImage(image_info,exception);
7766 msl_info.group_info[0].numImages=0;
7767 /* the first slot is used to point to the MSL file image */
7768 *msl_info.image=msl_image;
7769 if (*image != (Image *) NULL)
7770 MSLPushImage(&msl_info,*image);
7771 (void) xmlSubstituteEntitiesDefault(1);
7772 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7773 sax_modules.internalSubset=MSLInternalSubset;
7774 sax_modules.isStandalone=MSLIsStandalone;
7775 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7776 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7777 sax_modules.resolveEntity=MSLResolveEntity;
7778 sax_modules.getEntity=MSLGetEntity;
7779 sax_modules.entityDecl=MSLEntityDeclaration;
7780 sax_modules.notationDecl=MSLNotationDeclaration;
7781 sax_modules.attributeDecl=MSLAttributeDeclaration;
7782 sax_modules.elementDecl=MSLElementDeclaration;
7783 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7784 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7785 sax_modules.startDocument=MSLStartDocument;
7786 sax_modules.endDocument=MSLEndDocument;
7787 sax_modules.startElement=MSLStartElement;
7788 sax_modules.endElement=MSLEndElement;
7789 sax_modules.reference=MSLReference;
7790 sax_modules.characters=MSLCharacters;
7791 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7792 sax_modules.processingInstruction=MSLProcessingInstructions;
7793 sax_modules.comment=MSLComment;
7794 sax_modules.warning=MSLWarning;
7795 sax_modules.error=MSLError;
7796 sax_modules.fatalError=MSLError;
7797 sax_modules.getParameterEntity=MSLGetParameterEntity;
7798 sax_modules.cdataBlock=MSLCDataBlock;
7799 sax_modules.externalSubset=MSLExternalSubset;
7800 sax_handler=(&sax_modules);
7801 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7802 msl_image->filename);
7803 while (ReadBlobString(msl_image,message) != (char *) NULL)
7805 n=(ssize_t) strlen(message);
7808 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7811 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7812 if (msl_info.exception->severity >= ErrorException)
7815 if (msl_info.exception->severity == UndefinedException)
7816 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7817 xmlFreeParserCtxt(msl_info.parser);
7818 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7820 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7821 msl_info.group_info);
7822 if (*image == (Image *) NULL)
7823 *image=(*msl_info.image);
7824 if (msl_info.exception->severity != UndefinedException)
7825 return(MagickFalse);
7829 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7837 assert(image_info != (const ImageInfo *) NULL);
7838 assert(image_info->signature == MagickSignature);
7839 if (image_info->debug != MagickFalse)
7840 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7841 image_info->filename);
7842 assert(exception != (ExceptionInfo *) NULL);
7843 assert(exception->signature == MagickSignature);
7844 image=(Image *) NULL;
7845 (void) ProcessMSLScript(image_info,&image,exception);
7846 return(GetFirstImageInList(image));
7851 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7855 % R e g i s t e r M S L I m a g e %
7859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7861 % RegisterMSLImage() adds attributes for the MSL image format to
7862 % the list of supported formats. The attributes include the image format
7863 % tag, a method to read and/or write the format, whether the format
7864 % supports the saving of more than one frame to the same file or blob,
7865 % whether the format supports native in-memory I/O, and a brief
7866 % description of the format.
7868 % The format of the RegisterMSLImage method is:
7870 % size_t RegisterMSLImage(void)
7873 ModuleExport size_t RegisterMSLImage(void)
7878 entry=SetMagickInfo("MSL");
7879 #if defined(MAGICKCORE_XML_DELEGATE)
7880 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7881 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7883 entry->description=ConstantString("Magick Scripting Language");
7884 entry->module=ConstantString("MSL");
7885 (void) RegisterMagickInfo(entry);
7886 return(MagickImageCoderSignature);
7889 #if defined(MAGICKCORE_XML_DELEGATE)
7891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7895 % S e t M S L A t t r i b u t e s %
7899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7901 % SetMSLAttributes() ...
7903 % The format of the SetMSLAttributes method is:
7905 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7906 % const char *keyword,const char *value)
7908 % A description of each parameter follows:
7910 % o msl_info: the MSL info.
7912 % o keyword: the keyword.
7914 % o value: the value.
7917 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7944 assert(msl_info != (MSLInfo *) NULL);
7945 if (keyword == (const char *) NULL)
7947 if (value == (const char *) NULL)
7949 exception=msl_info->exception;
7951 attributes=msl_info->attributes[n];
7952 image_info=msl_info->image_info[n];
7953 draw_info=msl_info->draw_info[n];
7954 image=msl_info->image[n];
7960 if (LocaleCompare(keyword,"adjoin") == 0)
7965 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7967 ThrowMSLException(OptionError,"UnrecognizedType",value);
7968 image_info->adjoin=(MagickBooleanType) adjoin;
7971 if (LocaleCompare(keyword,"alpha") == 0)
7976 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7978 ThrowMSLException(OptionError,"UnrecognizedType",value);
7979 if (image != (Image *) NULL)
7980 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7984 if (LocaleCompare(keyword,"antialias") == 0)
7989 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7991 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7992 image_info->antialias=(MagickBooleanType) antialias;
7995 if (LocaleCompare(keyword,"area-limit") == 0)
8000 limit=MagickResourceInfinity;
8001 if (LocaleCompare(value,"unlimited") != 0)
8002 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
8003 (void) SetMagickResourceLimit(AreaResource,limit);
8006 if (LocaleCompare(keyword,"attenuate") == 0)
8008 (void) SetImageOption(image_info,keyword,value);
8011 if (LocaleCompare(keyword,"authenticate") == 0)
8013 (void) CloneString(&image_info->density,value);
8016 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8022 if (LocaleCompare(keyword,"background") == 0)
8024 (void) QueryColorCompliance(value,AllCompliance,
8025 &image_info->background_color,exception);
8028 if (LocaleCompare(keyword,"bias") == 0)
8030 if (image == (Image *) NULL)
8032 image->bias=StringToDoubleInterval(value,QuantumRange);
8035 if (LocaleCompare(keyword,"blue-primary") == 0)
8037 if (image == (Image *) NULL)
8039 flags=ParseGeometry(value,&geometry_info);
8040 image->chromaticity.blue_primary.x=geometry_info.rho;
8041 image->chromaticity.blue_primary.y=geometry_info.sigma;
8042 if ((flags & SigmaValue) == 0)
8043 image->chromaticity.blue_primary.y=
8044 image->chromaticity.blue_primary.x;
8047 if (LocaleCompare(keyword,"bordercolor") == 0)
8049 (void) QueryColorCompliance(value,AllCompliance,
8050 &image_info->border_color,exception);
8053 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8059 if (LocaleCompare(keyword,"density") == 0)
8061 (void) CloneString(&image_info->density,value);
8062 (void) CloneString(&draw_info->density,value);
8065 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8071 if (LocaleCompare(keyword,"fill") == 0)
8073 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8075 (void) SetImageOption(image_info,keyword,value);
8078 if (LocaleCompare(keyword,"filename") == 0)
8080 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8083 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8089 if (LocaleCompare(keyword,"gravity") == 0)
8094 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8096 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8097 (void) SetImageOption(image_info,keyword,value);
8100 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8106 if (LocaleCompare(keyword,"id") == 0)
8108 (void) SetImageProperty(attributes,keyword,value,exception);
8111 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8117 if (LocaleCompare(keyword,"magick") == 0)
8119 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8122 if (LocaleCompare(keyword,"mattecolor") == 0)
8124 (void) QueryColorCompliance(value,AllCompliance,
8125 &image_info->matte_color,exception);
8128 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8134 if (LocaleCompare(keyword,"pointsize") == 0)
8136 image_info->pointsize=StringToDouble(value,(char **) NULL);
8137 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8140 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8146 if (LocaleCompare(keyword,"quality") == 0)
8148 image_info->quality=StringToLong(value);
8149 if (image == (Image *) NULL)
8151 image->quality=StringToLong(value);
8159 if (LocaleCompare(keyword,"size") == 0)
8161 (void) CloneString(&image_info->size,value);
8164 if (LocaleCompare(keyword,"stroke") == 0)
8166 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8168 (void) SetImageOption(image_info,keyword,value);
8171 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8176 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8189 % U n r e g i s t e r M S L I m a g e %
8193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8195 % UnregisterMSLImage() removes format registrations made by the
8196 % MSL module from the list of supported formats.
8198 % The format of the UnregisterMSLImage method is:
8200 % UnregisterMSLImage(void)
8203 ModuleExport void UnregisterMSLImage(void)
8205 (void) UnregisterMagickInfo("MSL");
8208 #if defined(MAGICKCORE_XML_DELEGATE)
8210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8214 % W r i t e M S L I m a g e %
8218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8220 % WriteMSLImage() writes an image to a file in MVG image format.
8222 % The format of the WriteMSLImage method is:
8224 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8225 % Image *image,ExceptionInfo *exception)
8227 % A description of each parameter follows.
8229 % o image_info: the image info.
8231 % o image: The image.
8233 % o exception: return any errors or warnings in this structure.
8236 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8237 ExceptionInfo *exception)
8239 assert(image_info != (const ImageInfo *) NULL);
8240 assert(image_info->signature == MagickSignature);
8241 assert(image != (Image *) NULL);
8242 assert(image->signature == MagickSignature);
8243 if (image->debug != MagickFalse)
8244 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8245 (void) ReferenceImage(image);
8246 (void) ProcessMSLScript(image_info,&image,exception);