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,msl_info->exception);
1245 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
1246 if (blur_image == (Image *) NULL)
1248 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1249 msl_info->image[n]=blur_image;
1252 if (LocaleCompare((const char *) tag,"border") == 0)
1260 if (msl_info->image[n] == (Image *) NULL)
1262 ThrowMSLException(OptionError,"NoImagesDefined",
1263 (const char *) tag);
1266 SetGeometry(msl_info->image[n],&geometry);
1267 if (attributes != (const xmlChar **) NULL)
1268 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1270 keyword=(const char *) attributes[i++];
1271 attribute=InterpretImageProperties(msl_info->image_info[n],
1272 msl_info->attributes[n],(const char *) attributes[i],
1274 CloneString(&value,attribute);
1280 if (LocaleCompare(keyword,"compose") == 0)
1282 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1285 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1287 msl_info->image[n]->compose=(CompositeOperator) option;
1290 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1297 if (LocaleCompare(keyword, "fill") == 0)
1299 (void) QueryColorCompliance(value,AllCompliance,
1300 &msl_info->image[n]->border_color,&exception);
1303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1310 if (LocaleCompare(keyword,"geometry") == 0)
1312 flags=ParsePageGeometry(msl_info->image[n],value,
1313 &geometry,&exception);
1314 if ((flags & HeightValue) == 0)
1315 geometry.height=geometry.width;
1318 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1325 if (LocaleCompare(keyword,"height") == 0)
1327 geometry.height=StringToLong(value);
1330 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1337 if (LocaleCompare(keyword,"width") == 0)
1339 geometry.width=StringToLong(value);
1342 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1348 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1354 border_image=BorderImage(msl_info->image[n],&geometry,
1355 msl_info->image[n]->compose,msl_info->exception);
1356 if (border_image == (Image *) NULL)
1358 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1359 msl_info->image[n]=border_image;
1362 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1367 if (LocaleCompare((const char *) tag,"colorize") == 0)
1370 blend[MaxTextExtent];
1381 if (msl_info->image[n] == (Image *) NULL)
1383 ThrowMSLException(OptionError,"NoImagesDefined",
1384 (const char *) tag);
1387 GetPixelInfo(msl_info->image[n],&target);
1388 (void) CopyMagickString(blend,"100",MaxTextExtent);
1389 if (attributes != (const xmlChar **) NULL)
1390 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1392 keyword=(const char *) attributes[i++];
1393 attribute=InterpretImageProperties(msl_info->image_info[n],
1394 msl_info->attributes[n],(const char *) attributes[i],
1396 CloneString(&value,attribute);
1402 if (LocaleCompare(keyword,"blend") == 0)
1404 (void) CopyMagickString(blend,value,MaxTextExtent);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 if (LocaleCompare(keyword,"fill") == 0)
1416 (void) QueryColorCompliance(value,AllCompliance,
1417 &target,msl_info->exception);
1420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1426 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1432 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1433 msl_info->exception);
1434 if (colorize_image == (Image *) NULL)
1436 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1437 msl_info->image[n]=colorize_image;
1440 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1446 if (msl_info->image[n] == (Image *) NULL)
1448 ThrowMSLException(OptionError,"NoImagesDefined",
1449 (const char *) tag);
1453 NOTE: charcoal can have no attributes, since we use all the defaults!
1455 if (attributes != (const xmlChar **) NULL)
1457 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1459 keyword=(const char *) attributes[i++];
1460 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1461 msl_info->attributes[n],(const char *) attributes[i],&exception));
1467 if (LocaleCompare(keyword,"radius") == 0)
1469 radius=StringToDouble(value,(char **) NULL);
1472 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1478 if (LocaleCompare(keyword,"sigma") == 0)
1480 sigma = StringToLong( value );
1483 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1488 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1502 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1503 msl_info->exception);
1504 if (newImage == (Image *) NULL)
1506 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1507 msl_info->image[n]=newImage;
1511 if (LocaleCompare((const char *) tag,"chop") == 0)
1519 if (msl_info->image[n] == (Image *) NULL)
1521 ThrowMSLException(OptionError,"NoImagesDefined",
1522 (const char *) tag);
1525 SetGeometry(msl_info->image[n],&geometry);
1526 if (attributes != (const xmlChar **) NULL)
1527 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1529 keyword=(const char *) attributes[i++];
1530 attribute=InterpretImageProperties(msl_info->image_info[n],
1531 msl_info->attributes[n],(const char *) attributes[i],
1533 CloneString(&value,attribute);
1539 if (LocaleCompare(keyword,"geometry") == 0)
1541 flags=ParsePageGeometry(msl_info->image[n],value,
1542 &geometry,&exception);
1543 if ((flags & HeightValue) == 0)
1544 geometry.height=geometry.width;
1547 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1554 if (LocaleCompare(keyword,"height") == 0)
1556 geometry.height=StringToLong(value);
1559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1566 if (LocaleCompare(keyword,"width") == 0)
1568 geometry.width=StringToLong(value);
1571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1578 if (LocaleCompare(keyword,"x") == 0)
1580 geometry.x=StringToLong(value);
1583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1590 if (LocaleCompare(keyword,"y") == 0)
1592 geometry.y=StringToLong(value);
1595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1601 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1607 chop_image=ChopImage(msl_info->image[n],&geometry,
1608 msl_info->exception);
1609 if (chop_image == (Image *) NULL)
1611 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1612 msl_info->image[n]=chop_image;
1615 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1624 Color floodfill image.
1626 if (msl_info->image[n] == (Image *) NULL)
1628 ThrowMSLException(OptionError,"NoImagesDefined",
1629 (const char *) tag);
1632 draw_info=CloneDrawInfo(msl_info->image_info[n],
1633 msl_info->draw_info[n]);
1634 SetGeometry(msl_info->image[n],&geometry);
1635 paint_method=FloodfillMethod;
1636 if (attributes != (const xmlChar **) NULL)
1637 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1639 keyword=(const char *) attributes[i++];
1640 attribute=InterpretImageProperties(msl_info->image_info[n],
1641 msl_info->attributes[n],(const char *) attributes[i],
1643 CloneString(&value,attribute);
1649 if (LocaleCompare(keyword,"bordercolor") == 0)
1651 (void) QueryColorCompliance(value,AllCompliance,
1652 &target,&exception);
1653 paint_method=FillToBorderMethod;
1656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1663 if (LocaleCompare(keyword,"fill") == 0)
1665 (void) QueryColorCompliance(value,AllCompliance,
1666 &draw_info->fill,&exception);
1669 if (LocaleCompare(keyword,"fuzz") == 0)
1671 msl_info->image[n]->fuzz=StringToDouble(value,
1675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1682 if (LocaleCompare(keyword,"geometry") == 0)
1684 flags=ParsePageGeometry(msl_info->image[n],value,
1685 &geometry,&exception);
1686 if ((flags & HeightValue) == 0)
1687 geometry.height=geometry.width;
1688 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1689 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1693 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1700 if (LocaleCompare(keyword,"x") == 0)
1702 geometry.x=StringToLong(value);
1703 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1704 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1708 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1715 if (LocaleCompare(keyword,"y") == 0)
1717 geometry.y=StringToLong(value);
1718 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1719 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1723 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1735 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1736 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1737 MagickFalse : MagickTrue,msl_info->exception);
1738 draw_info=DestroyDrawInfo(draw_info);
1741 if (LocaleCompare((const char *) tag,"comment") == 0)
1743 if (LocaleCompare((const char *) tag,"composite") == 0)
1746 composite_geometry[MaxTextExtent];
1758 if (msl_info->image[n] == (Image *) NULL)
1760 ThrowMSLException(OptionError,"NoImagesDefined",
1761 (const char *) tag);
1764 composite_image=NewImageList();
1765 compose=OverCompositeOp;
1766 if (attributes != (const xmlChar **) NULL)
1767 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1769 keyword=(const char *) attributes[i++];
1770 attribute=InterpretImageProperties(msl_info->image_info[n],
1771 msl_info->attributes[n],(const char *) attributes[i],
1773 CloneString(&value,attribute);
1779 if (LocaleCompare(keyword,"compose") == 0)
1781 option=ParseCommandOption(MagickComposeOptions,
1784 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1786 compose=(CompositeOperator) option;
1794 if (LocaleCompare(keyword,"image") == 0)
1795 for (j=0; j < msl_info->n; j++)
1800 attribute=GetImageProperty(msl_info->attributes[j],"id",
1802 if ((attribute != (const char *) NULL) &&
1803 (LocaleCompare(attribute,value) == 0))
1805 composite_image=CloneImage(msl_info->image[j],0,0,
1806 MagickFalse,&exception);
1816 if (composite_image == (Image *) NULL)
1818 rotate_image=NewImageList();
1819 SetGeometry(msl_info->image[n],&geometry);
1820 if (attributes != (const xmlChar **) NULL)
1821 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1823 keyword=(const char *) attributes[i++];
1824 attribute=InterpretImageProperties(msl_info->image_info[n],
1825 msl_info->attributes[n],(const char *) attributes[i],
1827 CloneString(&value,attribute);
1833 if (LocaleCompare(keyword,"blend") == 0)
1835 (void) SetImageArtifact(composite_image,
1836 "compose:args",value);
1839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1846 if (LocaleCompare(keyword,"channel") == 0)
1848 option=ParseChannelOption(value);
1850 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1852 channel=(ChannelType) option;
1855 if (LocaleCompare(keyword, "color") == 0)
1857 (void) QueryColorCompliance(value,AllCompliance,
1858 &composite_image->background_color,&exception);
1861 if (LocaleCompare(keyword,"compose") == 0)
1863 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1870 if (LocaleCompare(keyword,"geometry") == 0)
1872 flags=ParsePageGeometry(msl_info->image[n],value,
1873 &geometry,&exception);
1874 if ((flags & HeightValue) == 0)
1875 geometry.height=geometry.width;
1878 if (LocaleCompare(keyword,"gravity") == 0)
1880 option=ParseCommandOption(MagickGravityOptions,
1883 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1885 msl_info->image[n]->gravity=(GravityType) option;
1888 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1895 if (LocaleCompare(keyword,"image") == 0)
1897 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1904 if (LocaleCompare(keyword,"mask") == 0)
1905 for (j=0; j < msl_info->n; j++)
1910 attribute=GetImageProperty(msl_info->attributes[j],"id",
1912 if ((attribute != (const char *) NULL) &&
1913 (LocaleCompare(value,value) == 0))
1915 SetImageType(composite_image,TrueColorMatteType,
1917 (void) CompositeImage(composite_image,
1918 CopyAlphaCompositeOp,msl_info->image[j],0,0,
1923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1930 if (LocaleCompare(keyword,"opacity") == 0)
1945 opacity=StringToLong(value);
1946 if (compose != DissolveCompositeOp)
1948 (void) SetImageAlpha(composite_image,(Quantum)
1949 opacity,&exception);
1952 (void) SetImageArtifact(msl_info->image[n],
1953 "compose:args",value);
1954 if (composite_image->matte != MagickTrue)
1955 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1957 composite_view=AcquireCacheView(composite_image);
1958 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1960 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1961 (ssize_t) composite_image->columns,1,&exception);
1962 for (x=0; x < (ssize_t) composite_image->columns; x++)
1964 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1965 SetPixelAlpha(composite_image,
1966 ClampToQuantum(opacity),q);
1967 q+=GetPixelChannels(composite_image);
1969 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1972 composite_view=DestroyCacheView(composite_view);
1975 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1982 if (LocaleCompare(keyword,"rotate") == 0)
1984 rotate_image=RotateImage(composite_image,
1985 StringToDouble(value,(char **) NULL),&exception);
1988 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1995 if (LocaleCompare(keyword,"tile") == 0)
2000 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2003 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2005 tile=(MagickBooleanType) option;
2007 if (rotate_image != (Image *) NULL)
2008 (void) SetImageArtifact(rotate_image,
2009 "compose:outside-overlay","false");
2011 (void) SetImageArtifact(composite_image,
2012 "compose:outside-overlay","false");
2013 image=msl_info->image[n];
2014 height=composite_image->rows;
2015 width=composite_image->columns;
2016 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2017 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2019 if (rotate_image != (Image *) NULL)
2020 (void) CompositeImage(image,compose,rotate_image,
2023 (void) CompositeImage(image,compose,
2024 composite_image,x,y,&exception);
2026 if (rotate_image != (Image *) NULL)
2027 rotate_image=DestroyImage(rotate_image);
2030 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2037 if (LocaleCompare(keyword,"x") == 0)
2039 geometry.x=StringToLong(value);
2042 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2049 if (LocaleCompare(keyword,"y") == 0)
2051 geometry.y=StringToLong(value);
2054 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2060 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2066 image=msl_info->image[n];
2067 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2068 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2069 (double) composite_image->rows,(double) geometry.x,(double)
2071 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2073 channel_mask=SetPixelChannelMask(image,channel);
2074 if (rotate_image == (Image *) NULL)
2075 CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
2082 geometry.x-=(ssize_t) (rotate_image->columns-
2083 composite_image->columns)/2;
2084 geometry.y-=(ssize_t) (rotate_image->rows-
2085 composite_image->rows)/2;
2086 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
2088 rotate_image=DestroyImage(rotate_image);
2090 (void) SetPixelChannelMask(image,channel_mask);
2091 composite_image=DestroyImage(composite_image);
2094 if (LocaleCompare((const char *) tag,"contrast") == 0)
2102 if (msl_info->image[n] == (Image *) NULL)
2104 ThrowMSLException(OptionError,"NoImagesDefined",
2105 (const char *) tag);
2108 sharpen=MagickFalse;
2109 if (attributes != (const xmlChar **) NULL)
2110 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2112 keyword=(const char *) attributes[i++];
2113 attribute=InterpretImageProperties(msl_info->image_info[n],
2114 msl_info->attributes[n],(const char *) attributes[i],
2116 CloneString(&value,attribute);
2122 if (LocaleCompare(keyword,"sharpen") == 0)
2124 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2127 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2129 sharpen=(MagickBooleanType) option;
2132 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2138 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2144 (void) ContrastImage(msl_info->image[n],sharpen,
2145 msl_info->exception);
2148 if (LocaleCompare((const char *) tag,"crop") == 0)
2156 if (msl_info->image[n] == (Image *) NULL)
2158 ThrowMSLException(OptionError,"NoImagesDefined",
2159 (const char *) tag);
2162 SetGeometry(msl_info->image[n],&geometry);
2163 if (attributes != (const xmlChar **) NULL)
2164 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2166 keyword=(const char *) attributes[i++];
2167 attribute=InterpretImageProperties(msl_info->image_info[n],
2168 msl_info->attributes[n],(const char *) attributes[i],
2170 CloneString(&value,attribute);
2176 if (LocaleCompare(keyword,"geometry") == 0)
2178 flags=ParseGravityGeometry(msl_info->image[n],value,
2179 &geometry,&exception);
2182 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2189 if (LocaleCompare(keyword,"height") == 0)
2191 geometry.height=StringToLong(value);
2194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2201 if (LocaleCompare(keyword,"width") == 0)
2203 geometry.width=StringToLong(value);
2206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2213 if (LocaleCompare(keyword,"x") == 0)
2215 geometry.x=StringToLong(value);
2218 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2225 if (LocaleCompare(keyword,"y") == 0)
2227 geometry.y=StringToLong(value);
2230 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2236 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2242 crop_image=CropImage(msl_info->image[n],&geometry,
2243 msl_info->exception);
2244 if (crop_image == (Image *) NULL)
2246 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2247 msl_info->image[n]=crop_image;
2250 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2256 Cycle-colormap image.
2258 if (msl_info->image[n] == (Image *) NULL)
2260 ThrowMSLException(OptionError,"NoImagesDefined",
2261 (const char *) tag);
2265 if (attributes != (const xmlChar **) NULL)
2266 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2268 keyword=(const char *) attributes[i++];
2269 attribute=InterpretImageProperties(msl_info->image_info[n],
2270 msl_info->attributes[n],(const char *) attributes[i],
2272 CloneString(&value,attribute);
2278 if (LocaleCompare(keyword,"display") == 0)
2280 display=StringToLong(value);
2283 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2289 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2295 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2298 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2303 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2311 if (msl_info->image[n] == (Image *) NULL)
2313 ThrowMSLException(OptionError,"NoImagesDefined",
2314 (const char *) tag);
2317 if (attributes != (const xmlChar **) NULL)
2318 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2320 keyword=(const char *) attributes[i++];
2321 attribute=InterpretImageProperties(msl_info->image_info[n],
2322 msl_info->attributes[n],(const char *) attributes[i],
2324 CloneString(&value,attribute);
2325 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2327 despeckle_image=DespeckleImage(msl_info->image[n],
2328 msl_info->exception);
2329 if (despeckle_image == (Image *) NULL)
2331 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2332 msl_info->image[n]=despeckle_image;
2335 if (LocaleCompare((const char *) tag,"display") == 0)
2337 if (msl_info->image[n] == (Image *) NULL)
2339 ThrowMSLException(OptionError,"NoImagesDefined",
2340 (const char *) tag);
2343 if (attributes != (const xmlChar **) NULL)
2344 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2346 keyword=(const char *) attributes[i++];
2347 attribute=InterpretImageProperties(msl_info->image_info[n],
2348 msl_info->attributes[n],(const char *) attributes[i],
2350 CloneString(&value,attribute);
2355 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2361 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2362 msl_info->exception);
2365 if (LocaleCompare((const char *) tag,"draw") == 0)
2368 text[MaxTextExtent];
2373 if (msl_info->image[n] == (Image *) NULL)
2375 ThrowMSLException(OptionError,"NoImagesDefined",
2376 (const char *) tag);
2379 draw_info=CloneDrawInfo(msl_info->image_info[n],
2380 msl_info->draw_info[n]);
2382 current=draw_info->affine;
2383 GetAffineMatrix(&affine);
2384 if (attributes != (const xmlChar **) NULL)
2385 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2387 keyword=(const char *) attributes[i++];
2388 attribute=InterpretImageProperties(msl_info->image_info[n],
2389 msl_info->attributes[n],(const char *) attributes[i],
2391 CloneString(&value,attribute);
2397 if (LocaleCompare(keyword,"affine") == 0)
2403 draw_info->affine.sx=StringToDouble(p,&p);
2406 draw_info->affine.rx=StringToDouble(p,&p);
2409 draw_info->affine.ry=StringToDouble(p,&p);
2412 draw_info->affine.sy=StringToDouble(p,&p);
2415 draw_info->affine.tx=StringToDouble(p,&p);
2418 draw_info->affine.ty=StringToDouble(p,&p);
2421 if (LocaleCompare(keyword,"align") == 0)
2423 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2426 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2428 draw_info->align=(AlignType) option;
2431 if (LocaleCompare(keyword,"antialias") == 0)
2433 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2436 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2438 draw_info->stroke_antialias=(MagickBooleanType) option;
2439 draw_info->text_antialias=(MagickBooleanType) option;
2442 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2449 if (LocaleCompare(keyword,"density") == 0)
2451 CloneString(&draw_info->density,value);
2454 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2461 if (LocaleCompare(keyword,"encoding") == 0)
2463 CloneString(&draw_info->encoding,value);
2466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2473 if (LocaleCompare(keyword, "fill") == 0)
2475 (void) QueryColorCompliance(value,AllCompliance,
2476 &draw_info->fill,&exception);
2479 if (LocaleCompare(keyword,"family") == 0)
2481 CloneString(&draw_info->family,value);
2484 if (LocaleCompare(keyword,"font") == 0)
2486 CloneString(&draw_info->font,value);
2489 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2496 if (LocaleCompare(keyword,"geometry") == 0)
2498 flags=ParsePageGeometry(msl_info->image[n],value,
2499 &geometry,&exception);
2500 if ((flags & HeightValue) == 0)
2501 geometry.height=geometry.width;
2504 if (LocaleCompare(keyword,"gravity") == 0)
2506 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2509 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2511 draw_info->gravity=(GravityType) option;
2514 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2521 if (LocaleCompare(keyword,"primitive") == 0)
2523 CloneString(&draw_info->primitive,value);
2526 if (LocaleCompare(keyword,"pointsize") == 0)
2528 draw_info->pointsize=StringToDouble(value,
2532 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2539 if (LocaleCompare(keyword,"rotate") == 0)
2541 angle=StringToDouble(value,(char **) NULL);
2542 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2543 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2544 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2545 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2555 if (LocaleCompare(keyword,"scale") == 0)
2557 flags=ParseGeometry(value,&geometry_info);
2558 if ((flags & SigmaValue) == 0)
2559 geometry_info.sigma=1.0;
2560 affine.sx=geometry_info.rho;
2561 affine.sy=geometry_info.sigma;
2564 if (LocaleCompare(keyword,"skewX") == 0)
2566 angle=StringToDouble(value,(char **) NULL);
2567 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2570 if (LocaleCompare(keyword,"skewY") == 0)
2572 angle=StringToDouble(value,(char **) NULL);
2573 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2576 if (LocaleCompare(keyword,"stretch") == 0)
2578 option=ParseCommandOption(MagickStretchOptions,
2581 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2583 draw_info->stretch=(StretchType) option;
2586 if (LocaleCompare(keyword, "stroke") == 0)
2588 (void) QueryColorCompliance(value,AllCompliance,
2589 &draw_info->stroke,&exception);
2592 if (LocaleCompare(keyword,"strokewidth") == 0)
2594 draw_info->stroke_width=StringToLong(value);
2597 if (LocaleCompare(keyword,"style") == 0)
2599 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2602 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2604 draw_info->style=(StyleType) option;
2607 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2614 if (LocaleCompare(keyword,"text") == 0)
2616 CloneString(&draw_info->text,value);
2619 if (LocaleCompare(keyword,"translate") == 0)
2621 flags=ParseGeometry(value,&geometry_info);
2622 if ((flags & SigmaValue) == 0)
2623 geometry_info.sigma=1.0;
2624 affine.tx=geometry_info.rho;
2625 affine.ty=geometry_info.sigma;
2628 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2635 if (LocaleCompare(keyword, "undercolor") == 0)
2637 (void) QueryColorCompliance(value,AllCompliance,
2638 &draw_info->undercolor,&exception);
2641 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2648 if (LocaleCompare(keyword,"weight") == 0)
2650 draw_info->weight=StringToLong(value);
2653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2660 if (LocaleCompare(keyword,"x") == 0)
2662 geometry.x=StringToLong(value);
2665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2672 if (LocaleCompare(keyword,"y") == 0)
2674 geometry.y=StringToLong(value);
2677 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2689 (void) FormatLocaleString(text,MaxTextExtent,
2690 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2691 geometry.height,(double) geometry.x,(double) geometry.y);
2692 CloneString(&draw_info->geometry,text);
2693 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2694 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2695 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2696 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2697 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2699 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2701 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2702 draw_info=DestroyDrawInfo(draw_info);
2705 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2710 if (LocaleCompare((const char *) tag,"edge") == 0)
2718 if (msl_info->image[n] == (Image *) NULL)
2720 ThrowMSLException(OptionError,"NoImagesDefined",
2721 (const char *) tag);
2724 if (attributes != (const xmlChar **) NULL)
2725 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2727 keyword=(const char *) attributes[i++];
2728 attribute=InterpretImageProperties(msl_info->image_info[n],
2729 msl_info->attributes[n],(const char *) attributes[i],
2731 CloneString(&value,attribute);
2737 if (LocaleCompare(keyword,"geometry") == 0)
2739 flags=ParseGeometry(value,&geometry_info);
2740 if ((flags & SigmaValue) == 0)
2741 geometry_info.sigma=1.0;
2744 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2751 if (LocaleCompare(keyword,"radius") == 0)
2753 geometry_info.rho=StringToDouble(value,(char **) NULL);
2756 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2762 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2768 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2769 geometry_info.sigma,msl_info->exception);
2770 if (edge_image == (Image *) NULL)
2772 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2773 msl_info->image[n]=edge_image;
2776 if (LocaleCompare((const char *) tag,"emboss") == 0)
2784 if (msl_info->image[n] == (Image *) NULL)
2786 ThrowMSLException(OptionError,"NoImagesDefined",
2787 (const char *) tag);
2790 if (attributes != (const xmlChar **) NULL)
2791 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2793 keyword=(const char *) attributes[i++];
2794 attribute=InterpretImageProperties(msl_info->image_info[n],
2795 msl_info->attributes[n],(const char *) attributes[i],
2797 CloneString(&value,attribute);
2803 if (LocaleCompare(keyword,"geometry") == 0)
2805 flags=ParseGeometry(value,&geometry_info);
2806 if ((flags & SigmaValue) == 0)
2807 geometry_info.sigma=1.0;
2810 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2817 if (LocaleCompare(keyword,"radius") == 0)
2819 geometry_info.rho=StringToDouble(value,
2823 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2830 if (LocaleCompare(keyword,"sigma") == 0)
2832 geometry_info.sigma=StringToLong(value);
2835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2847 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2848 geometry_info.sigma,msl_info->exception);
2849 if (emboss_image == (Image *) NULL)
2851 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2852 msl_info->image[n]=emboss_image;
2855 if (LocaleCompare((const char *) tag,"enhance") == 0)
2863 if (msl_info->image[n] == (Image *) NULL)
2865 ThrowMSLException(OptionError,"NoImagesDefined",
2866 (const char *) tag);
2869 if (attributes != (const xmlChar **) NULL)
2870 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2872 keyword=(const char *) attributes[i++];
2873 attribute=InterpretImageProperties(msl_info->image_info[n],
2874 msl_info->attributes[n],(const char *) attributes[i],
2876 CloneString(&value,attribute);
2877 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2879 enhance_image=EnhanceImage(msl_info->image[n],
2880 msl_info->exception);
2881 if (enhance_image == (Image *) NULL)
2883 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2884 msl_info->image[n]=enhance_image;
2887 if (LocaleCompare((const char *) tag,"equalize") == 0)
2892 if (msl_info->image[n] == (Image *) NULL)
2894 ThrowMSLException(OptionError,"NoImagesDefined",
2895 (const char *) tag);
2898 if (attributes != (const xmlChar **) NULL)
2899 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2901 keyword=(const char *) attributes[i++];
2902 attribute=InterpretImageProperties(msl_info->image_info[n],
2903 msl_info->attributes[n],(const char *) attributes[i],
2905 CloneString(&value,attribute);
2910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2916 (void) EqualizeImage(msl_info->image[n],
2917 msl_info->exception);
2920 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2925 if (LocaleCompare((const char *) tag, "flatten") == 0)
2927 if (msl_info->image[n] == (Image *) NULL)
2929 ThrowMSLException(OptionError,"NoImagesDefined",
2930 (const char *) tag);
2934 /* no attributes here */
2936 /* process the image */
2941 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2942 msl_info->exception);
2943 if (newImage == (Image *) NULL)
2945 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2946 msl_info->image[n]=newImage;
2950 if (LocaleCompare((const char *) tag,"flip") == 0)
2958 if (msl_info->image[n] == (Image *) NULL)
2960 ThrowMSLException(OptionError,"NoImagesDefined",
2961 (const char *) tag);
2964 if (attributes != (const xmlChar **) NULL)
2965 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2967 keyword=(const char *) attributes[i++];
2968 attribute=InterpretImageProperties(msl_info->image_info[n],
2969 msl_info->attributes[n],(const char *) attributes[i],
2971 CloneString(&value,attribute);
2972 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2974 flip_image=FlipImage(msl_info->image[n],
2975 msl_info->exception);
2976 if (flip_image == (Image *) NULL)
2978 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2979 msl_info->image[n]=flip_image;
2982 if (LocaleCompare((const char *) tag,"flop") == 0)
2990 if (msl_info->image[n] == (Image *) NULL)
2992 ThrowMSLException(OptionError,"NoImagesDefined",
2993 (const char *) tag);
2996 if (attributes != (const xmlChar **) NULL)
2997 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2999 keyword=(const char *) attributes[i++];
3000 attribute=InterpretImageProperties(msl_info->image_info[n],
3001 msl_info->attributes[n],(const char *) attributes[i],
3003 CloneString(&value,attribute);
3004 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3006 flop_image=FlopImage(msl_info->image[n],
3007 msl_info->exception);
3008 if (flop_image == (Image *) NULL)
3010 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3011 msl_info->image[n]=flop_image;
3014 if (LocaleCompare((const char *) tag,"frame") == 0)
3025 if (msl_info->image[n] == (Image *) NULL)
3027 ThrowMSLException(OptionError,"NoImagesDefined",
3028 (const char *) tag);
3031 SetGeometry(msl_info->image[n],&geometry);
3032 if (attributes != (const xmlChar **) NULL)
3033 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3035 keyword=(const char *) attributes[i++];
3036 attribute=InterpretImageProperties(msl_info->image_info[n],
3037 msl_info->attributes[n],(const char *) attributes[i],
3039 CloneString(&value,attribute);
3045 if (LocaleCompare(keyword,"compose") == 0)
3047 option=ParseCommandOption(MagickComposeOptions,
3050 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3052 msl_info->image[n]->compose=(CompositeOperator) option;
3055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3062 if (LocaleCompare(keyword, "fill") == 0)
3064 (void) QueryColorCompliance(value,AllCompliance,
3065 &msl_info->image[n]->matte_color,&exception);
3068 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3075 if (LocaleCompare(keyword,"geometry") == 0)
3077 flags=ParsePageGeometry(msl_info->image[n],value,
3078 &geometry,&exception);
3079 if ((flags & HeightValue) == 0)
3080 geometry.height=geometry.width;
3081 frame_info.width=geometry.width;
3082 frame_info.height=geometry.height;
3083 frame_info.outer_bevel=geometry.x;
3084 frame_info.inner_bevel=geometry.y;
3087 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3094 if (LocaleCompare(keyword,"height") == 0)
3096 frame_info.height=StringToLong(value);
3099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3106 if (LocaleCompare(keyword,"inner") == 0)
3108 frame_info.inner_bevel=StringToLong(value);
3111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3118 if (LocaleCompare(keyword,"outer") == 0)
3120 frame_info.outer_bevel=StringToLong(value);
3123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3130 if (LocaleCompare(keyword,"width") == 0)
3132 frame_info.width=StringToLong(value);
3135 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3141 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3147 frame_info.x=(ssize_t) frame_info.width;
3148 frame_info.y=(ssize_t) frame_info.height;
3149 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3150 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3151 frame_image=FrameImage(msl_info->image[n],&frame_info,
3152 msl_info->image[n]->compose,msl_info->exception);
3153 if (frame_image == (Image *) NULL)
3155 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3156 msl_info->image[n]=frame_image;
3159 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3164 if (LocaleCompare((const char *) tag,"gamma") == 0)
3167 gamma[MaxTextExtent];
3175 if (msl_info->image[n] == (Image *) NULL)
3177 ThrowMSLException(OptionError,"NoImagesDefined",
3178 (const char *) tag);
3181 channel=UndefinedChannel;
3186 if (attributes != (const xmlChar **) NULL)
3187 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3189 keyword=(const char *) attributes[i++];
3190 attribute=InterpretImageProperties(msl_info->image_info[n],
3191 msl_info->attributes[n],(const char *) attributes[i],
3193 CloneString(&value,attribute);
3199 if (LocaleCompare(keyword,"blue") == 0)
3201 pixel.blue=StringToDouble(value,(char **) NULL);
3204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3211 if (LocaleCompare(keyword,"channel") == 0)
3213 option=ParseChannelOption(value);
3215 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3217 channel=(ChannelType) option;
3220 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3227 if (LocaleCompare(keyword,"gamma") == 0)
3229 (void) CopyMagickString(gamma,value,MaxTextExtent);
3232 if (LocaleCompare(keyword,"green") == 0)
3234 pixel.green=StringToDouble(value,(char **) NULL);
3237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3244 if (LocaleCompare(keyword,"red") == 0)
3246 pixel.red=StringToDouble(value,(char **) NULL);
3249 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3262 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3263 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3264 (void) GammaImage(msl_info->image[n],atof(gamma),
3265 msl_info->exception);
3268 else if (LocaleCompare((const char *) tag,"get") == 0)
3270 if (msl_info->image[n] == (Image *) NULL)
3272 ThrowMSLException(OptionError,"NoImagesDefined",
3273 (const char *) tag);
3276 if (attributes == (const xmlChar **) NULL)
3278 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3280 keyword=(const char *) attributes[i++];
3281 CloneString(&value,(const char *) attributes[i]);
3282 (void) CopyMagickString(key,value,MaxTextExtent);
3288 if (LocaleCompare(keyword,"height") == 0)
3290 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3291 (double) msl_info->image[n]->rows);
3292 (void) SetImageProperty(msl_info->attributes[n],key,value,
3296 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3301 if (LocaleCompare(keyword,"width") == 0)
3303 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3304 (double) msl_info->image[n]->columns);
3305 (void) SetImageProperty(msl_info->attributes[n],key,value,
3309 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3313 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3320 else if (LocaleCompare((const char *) tag, "group") == 0)
3322 msl_info->number_groups++;
3323 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3324 msl_info->group_info,msl_info->number_groups+1UL,
3325 sizeof(*msl_info->group_info));
3328 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3333 if (LocaleCompare((const char *) tag,"image") == 0)
3335 MSLPushImage(msl_info,(Image *) NULL);
3336 if (attributes == (const xmlChar **) NULL)
3338 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3340 keyword=(const char *) attributes[i++];
3341 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3342 msl_info->attributes[n],(const char *) attributes[i],&exception));
3348 if (LocaleCompare(keyword,"color") == 0)
3353 (void) CopyMagickString(msl_info->image_info[n]->filename,
3354 "xc:",MaxTextExtent);
3355 (void) ConcatenateMagickString(msl_info->image_info[n]->
3356 filename,value,MaxTextExtent);
3357 next_image=ReadImage(msl_info->image_info[n],&exception);
3358 CatchException(&exception);
3359 if (next_image == (Image *) NULL)
3361 if (msl_info->image[n] == (Image *) NULL)
3362 msl_info->image[n]=next_image;
3369 Link image into image list.
3371 p=msl_info->image[n];
3372 while (p->next != (Image *) NULL)
3373 p=GetNextImageInList(p);
3374 next_image->previous=p;
3379 (void) SetMSLAttributes(msl_info,keyword,value);
3384 (void) SetMSLAttributes(msl_info,keyword,value);
3391 if (LocaleCompare((const char *) tag,"implode") == 0)
3399 if (msl_info->image[n] == (Image *) NULL)
3401 ThrowMSLException(OptionError,"NoImagesDefined",
3402 (const char *) tag);
3405 if (attributes != (const xmlChar **) NULL)
3406 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3408 keyword=(const char *) attributes[i++];
3409 attribute=InterpretImageProperties(msl_info->image_info[n],
3410 msl_info->attributes[n],(const char *) attributes[i],
3412 CloneString(&value,attribute);
3418 if (LocaleCompare(keyword,"amount") == 0)
3420 geometry_info.rho=StringToDouble(value,
3424 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3431 if (LocaleCompare(keyword,"geometry") == 0)
3433 flags=ParseGeometry(value,&geometry_info);
3434 if ((flags & SigmaValue) == 0)
3435 geometry_info.sigma=1.0;
3438 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3444 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3450 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3451 msl_info->image[n]->interpolate,msl_info->exception);
3452 if (implode_image == (Image *) NULL)
3454 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3455 msl_info->image[n]=implode_image;
3458 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3463 if (LocaleCompare((const char *) tag,"label") == 0)
3465 if (LocaleCompare((const char *) tag, "level") == 0)
3468 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3470 if (msl_info->image[n] == (Image *) NULL)
3472 ThrowMSLException(OptionError,"NoImagesDefined",
3473 (const char *) tag);
3476 if (attributes == (const xmlChar **) NULL)
3478 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3480 keyword=(const char *) attributes[i++];
3481 CloneString(&value,(const char *) attributes[i]);
3482 (void) CopyMagickString(key,value,MaxTextExtent);
3488 if (LocaleCompare(keyword,"black") == 0)
3490 levelBlack = StringToDouble(value,(char **) NULL);
3493 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3499 if (LocaleCompare(keyword,"gamma") == 0)
3501 levelGamma = StringToDouble(value,(char **) NULL);
3504 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3510 if (LocaleCompare(keyword,"white") == 0)
3512 levelWhite = StringToDouble(value,(char **) NULL);
3515 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3520 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3527 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3528 msl_info->exception);
3535 if (LocaleCompare((const char *) tag,"magnify") == 0)
3543 if (msl_info->image[n] == (Image *) NULL)
3545 ThrowMSLException(OptionError,"NoImagesDefined",
3546 (const char *) tag);
3549 if (attributes != (const xmlChar **) NULL)
3550 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3552 keyword=(const char *) attributes[i++];
3553 attribute=InterpretImageProperties(msl_info->image_info[n],
3554 msl_info->attributes[n],(const char *) attributes[i],
3556 CloneString(&value,attribute);
3557 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3559 magnify_image=MagnifyImage(msl_info->image[n],
3560 msl_info->exception);
3561 if (magnify_image == (Image *) NULL)
3563 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3564 msl_info->image[n]=magnify_image;
3567 if (LocaleCompare((const char *) tag,"map") == 0)
3581 if (msl_info->image[n] == (Image *) NULL)
3583 ThrowMSLException(OptionError,"NoImagesDefined",
3584 (const char *) tag);
3587 affinity_image=NewImageList();
3589 if (attributes != (const xmlChar **) NULL)
3590 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3592 keyword=(const char *) attributes[i++];
3593 attribute=InterpretImageProperties(msl_info->image_info[n],
3594 msl_info->attributes[n],(const char *) attributes[i],
3596 CloneString(&value,attribute);
3602 if (LocaleCompare(keyword,"dither") == 0)
3604 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3607 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3609 dither=(MagickBooleanType) option;
3612 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3619 if (LocaleCompare(keyword,"image") == 0)
3620 for (j=0; j < msl_info->n; j++)
3625 attribute=GetImageProperty(msl_info->attributes[j],"id",
3627 if ((attribute != (const char *) NULL) &&
3628 (LocaleCompare(attribute,value) == 0))
3630 affinity_image=CloneImage(msl_info->image[j],0,0,
3631 MagickFalse,&exception);
3639 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3645 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3646 quantize_info->dither=dither;
3647 (void) RemapImages(quantize_info,msl_info->image[n],
3648 affinity_image,&exception);
3649 quantize_info=DestroyQuantizeInfo(quantize_info);
3650 affinity_image=DestroyImage(affinity_image);
3653 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3665 Matte floodfill image.
3668 if (msl_info->image[n] == (Image *) NULL)
3670 ThrowMSLException(OptionError,"NoImagesDefined",
3671 (const char *) tag);
3674 SetGeometry(msl_info->image[n],&geometry);
3675 paint_method=FloodfillMethod;
3676 if (attributes != (const xmlChar **) NULL)
3677 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3679 keyword=(const char *) attributes[i++];
3680 attribute=InterpretImageProperties(msl_info->image_info[n],
3681 msl_info->attributes[n],(const char *) attributes[i],
3683 CloneString(&value,attribute);
3689 if (LocaleCompare(keyword,"bordercolor") == 0)
3691 (void) QueryColorCompliance(value,AllCompliance,
3692 &target,&exception);
3693 paint_method=FillToBorderMethod;
3696 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3703 if (LocaleCompare(keyword,"fuzz") == 0)
3705 msl_info->image[n]->fuzz=StringToDouble(value,
3709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3716 if (LocaleCompare(keyword,"geometry") == 0)
3718 flags=ParsePageGeometry(msl_info->image[n],value,
3719 &geometry,&exception);
3720 if ((flags & HeightValue) == 0)
3721 geometry.height=geometry.width;
3722 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3723 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3727 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3734 if (LocaleCompare(keyword,"opacity") == 0)
3736 opacity=StringToDouble(value,(char **) NULL);
3739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3746 if (LocaleCompare(keyword,"x") == 0)
3748 geometry.x=StringToLong(value);
3749 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3750 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3754 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3761 if (LocaleCompare(keyword,"y") == 0)
3763 geometry.y=StringToLong(value);
3764 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3765 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3769 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3781 draw_info=CloneDrawInfo(msl_info->image_info[n],
3782 msl_info->draw_info[n]);
3783 draw_info->fill.alpha=ClampToQuantum(opacity);
3784 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3785 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3786 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3787 MagickFalse : MagickTrue,msl_info->exception);
3788 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
3789 draw_info=DestroyDrawInfo(draw_info);
3792 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3798 Median-filter image.
3800 if (msl_info->image[n] == (Image *) NULL)
3802 ThrowMSLException(OptionError,"NoImagesDefined",
3803 (const char *) tag);
3806 if (attributes != (const xmlChar **) NULL)
3807 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3809 keyword=(const char *) attributes[i++];
3810 attribute=InterpretImageProperties(msl_info->image_info[n],
3811 msl_info->attributes[n],(const char *) attributes[i],
3813 CloneString(&value,attribute);
3819 if (LocaleCompare(keyword,"geometry") == 0)
3821 flags=ParseGeometry(value,&geometry_info);
3822 if ((flags & SigmaValue) == 0)
3823 geometry_info.sigma=1.0;
3826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3833 if (LocaleCompare(keyword,"radius") == 0)
3835 geometry_info.rho=StringToDouble(value,
3839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3845 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3851 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3852 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3853 msl_info->exception);
3854 if (median_image == (Image *) NULL)
3856 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3857 msl_info->image[n]=median_image;
3860 if (LocaleCompare((const char *) tag,"minify") == 0)
3868 if (msl_info->image[n] == (Image *) NULL)
3870 ThrowMSLException(OptionError,"NoImagesDefined",
3871 (const char *) tag);
3874 if (attributes != (const xmlChar **) NULL)
3875 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3877 keyword=(const char *) attributes[i++];
3878 attribute=InterpretImageProperties(msl_info->image_info[n],
3879 msl_info->attributes[n],(const char *) attributes[i],
3881 CloneString(&value,attribute);
3882 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3884 minify_image=MinifyImage(msl_info->image[n],
3885 msl_info->exception);
3886 if (minify_image == (Image *) NULL)
3888 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3889 msl_info->image[n]=minify_image;
3892 if (LocaleCompare((const char *) tag,"msl") == 0 )
3894 if (LocaleCompare((const char *) tag,"modulate") == 0)
3897 modulate[MaxTextExtent];
3902 if (msl_info->image[n] == (Image *) NULL)
3904 ThrowMSLException(OptionError,"NoImagesDefined",
3905 (const char *) tag);
3908 geometry_info.rho=100.0;
3909 geometry_info.sigma=100.0;
3910 geometry_info.xi=100.0;
3911 if (attributes != (const xmlChar **) NULL)
3912 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3914 keyword=(const char *) attributes[i++];
3915 attribute=InterpretImageProperties(msl_info->image_info[n],
3916 msl_info->attributes[n],(const char *) attributes[i],
3918 CloneString(&value,attribute);
3924 if (LocaleCompare(keyword,"blackness") == 0)
3926 geometry_info.rho=StringToDouble(value,
3930 if (LocaleCompare(keyword,"brightness") == 0)
3932 geometry_info.rho=StringToDouble(value,
3936 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3943 if (LocaleCompare(keyword,"factor") == 0)
3945 flags=ParseGeometry(value,&geometry_info);
3948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3955 if (LocaleCompare(keyword,"hue") == 0)
3957 geometry_info.xi=StringToDouble(value,
3961 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3968 if (LocaleCompare(keyword,"lightness") == 0)
3970 geometry_info.rho=StringToDouble(value,
3974 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3981 if (LocaleCompare(keyword,"saturation") == 0)
3983 geometry_info.sigma=StringToDouble(value,
3987 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3994 if (LocaleCompare(keyword,"whiteness") == 0)
3996 geometry_info.sigma=StringToDouble(value,
4000 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4006 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4012 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4013 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4014 (void) ModulateImage(msl_info->image[n],modulate,
4015 msl_info->exception);
4018 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4023 if (LocaleCompare((const char *) tag,"negate") == 0)
4031 if (msl_info->image[n] == (Image *) NULL)
4033 ThrowMSLException(OptionError,"NoImagesDefined",
4034 (const char *) tag);
4038 if (attributes != (const xmlChar **) NULL)
4039 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4041 keyword=(const char *) attributes[i++];
4042 attribute=InterpretImageProperties(msl_info->image_info[n],
4043 msl_info->attributes[n],(const char *) attributes[i],
4045 CloneString(&value,attribute);
4051 if (LocaleCompare(keyword,"channel") == 0)
4053 option=ParseChannelOption(value);
4055 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4057 channel=(ChannelType) option;
4060 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4067 if (LocaleCompare(keyword,"gray") == 0)
4069 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4072 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4074 gray=(MagickBooleanType) option;
4077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4083 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4089 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4090 (void) NegateImage(msl_info->image[n],gray,
4091 msl_info->exception);
4092 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4095 if (LocaleCompare((const char *) tag,"normalize") == 0)
4100 if (msl_info->image[n] == (Image *) NULL)
4102 ThrowMSLException(OptionError,"NoImagesDefined",
4103 (const char *) tag);
4106 if (attributes != (const xmlChar **) NULL)
4107 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4109 keyword=(const char *) attributes[i++];
4110 attribute=InterpretImageProperties(msl_info->image_info[n],
4111 msl_info->attributes[n],(const char *) attributes[i],
4113 CloneString(&value,attribute);
4119 if (LocaleCompare(keyword,"channel") == 0)
4121 option=ParseChannelOption(value);
4123 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4125 channel=(ChannelType) option;
4128 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4140 (void) NormalizeImage(msl_info->image[n],
4141 msl_info->exception);
4144 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4149 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4157 if (msl_info->image[n] == (Image *) NULL)
4159 ThrowMSLException(OptionError,"NoImagesDefined",
4160 (const char *) tag);
4163 if (attributes != (const xmlChar **) NULL)
4164 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4166 keyword=(const char *) attributes[i++];
4167 attribute=InterpretImageProperties(msl_info->image_info[n],
4168 msl_info->attributes[n],(const char *) attributes[i],
4170 CloneString(&value,attribute);
4176 if (LocaleCompare(keyword,"geometry") == 0)
4178 flags=ParseGeometry(value,&geometry_info);
4179 if ((flags & SigmaValue) == 0)
4180 geometry_info.sigma=1.0;
4183 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4190 if (LocaleCompare(keyword,"radius") == 0)
4192 geometry_info.rho=StringToDouble(value,
4196 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4208 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4209 geometry_info.sigma,msl_info->exception);
4210 if (paint_image == (Image *) NULL)
4212 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4213 msl_info->image[n]=paint_image;
4216 if (LocaleCompare((const char *) tag,"opaque") == 0)
4225 if (msl_info->image[n] == (Image *) NULL)
4227 ThrowMSLException(OptionError,"NoImagesDefined",
4228 (const char *) tag);
4231 (void) QueryColorCompliance("none",AllCompliance,&target,
4233 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4235 if (attributes != (const xmlChar **) NULL)
4236 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4238 keyword=(const char *) attributes[i++];
4239 attribute=InterpretImageProperties(msl_info->image_info[n],
4240 msl_info->attributes[n],(const char *) attributes[i],
4242 CloneString(&value,attribute);
4248 if (LocaleCompare(keyword,"channel") == 0)
4250 option=ParseChannelOption(value);
4252 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4254 channel=(ChannelType) option;
4257 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4264 if (LocaleCompare(keyword,"fill") == 0)
4266 (void) QueryColorCompliance(value,AllCompliance,
4267 &fill_color,&exception);
4270 if (LocaleCompare(keyword,"fuzz") == 0)
4272 msl_info->image[n]->fuzz=StringToDouble(value,
4276 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4282 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4288 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4289 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4290 MagickFalse,msl_info->exception);
4291 (void) SetPixelChannelMapMask(msl_info->image[n],channel_mask);
4294 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4299 if (LocaleCompare((const char *) tag,"print") == 0)
4301 if (attributes == (const xmlChar **) NULL)
4303 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4305 keyword=(const char *) attributes[i++];
4306 attribute=InterpretImageProperties(msl_info->image_info[n],
4307 msl_info->attributes[n],(const char *) attributes[i],
4309 CloneString(&value,attribute);
4315 if (LocaleCompare(keyword,"output") == 0)
4317 (void) FormatLocaleFile(stdout,"%s",value);
4320 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4325 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4332 if (LocaleCompare((const char *) tag, "profile") == 0)
4334 if (msl_info->image[n] == (Image *) NULL)
4336 ThrowMSLException(OptionError,"NoImagesDefined",
4337 (const char *) tag);
4340 if (attributes == (const xmlChar **) NULL)
4342 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4356 keyword=(const char *) attributes[i++];
4357 attribute=InterpretImageProperties(msl_info->image_info[n],
4358 msl_info->attributes[n],(const char *) attributes[i],
4360 CloneString(&value,attribute);
4361 if (*keyword == '+')
4364 Remove a profile from the image.
4366 (void) ProfileImage(msl_info->image[n],keyword,
4367 (const unsigned char *) NULL,0,&exception);
4371 Associate a profile with the image.
4373 profile_info=CloneImageInfo(msl_info->image_info[n]);
4374 profile=GetImageProfile(msl_info->image[n],"iptc");
4375 if (profile != (StringInfo *) NULL)
4376 profile_info->profile=(void *) CloneStringInfo(profile);
4377 profile_image=GetImageCache(profile_info,keyword,&exception);
4378 profile_info=DestroyImageInfo(profile_info);
4379 if (profile_image == (Image *) NULL)
4382 name[MaxTextExtent],
4383 filename[MaxTextExtent];
4391 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4392 (void) CopyMagickString(name,keyword,MaxTextExtent);
4393 for (p=filename; *p != '\0'; p++)
4394 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4395 (IsPathAccessible(keyword) == MagickFalse))
4401 Look for profile name (e.g. name:profile).
4403 (void) CopyMagickString(name,filename,(size_t)
4405 for (q=filename; *q != '\0'; q++)
4409 profile=FileToStringInfo(filename,~0UL,&exception);
4410 if (profile != (StringInfo *) NULL)
4412 (void) ProfileImage(msl_info->image[n],name,
4413 GetStringInfoDatum(profile),(size_t)
4414 GetStringInfoLength(profile),&exception);
4415 profile=DestroyStringInfo(profile);
4419 ResetImageProfileIterator(profile_image);
4420 name=GetNextImageProfile(profile_image);
4421 while (name != (const char *) NULL)
4423 profile=GetImageProfile(profile_image,name);
4424 if (profile != (StringInfo *) NULL)
4425 (void) ProfileImage(msl_info->image[n],name,
4426 GetStringInfoDatum(profile),(size_t)
4427 GetStringInfoLength(profile),&exception);
4428 name=GetNextImageProfile(profile_image);
4430 profile_image=DestroyImage(profile_image);
4434 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4439 if (LocaleCompare((const char *) tag,"quantize") == 0)
4447 if (msl_info->image[n] == (Image *) NULL)
4449 ThrowMSLException(OptionError,"NoImagesDefined",
4450 (const char *) tag);
4453 GetQuantizeInfo(&quantize_info);
4454 if (attributes != (const xmlChar **) NULL)
4455 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4457 keyword=(const char *) attributes[i++];
4458 attribute=InterpretImageProperties(msl_info->image_info[n],
4459 msl_info->attributes[n],(const char *) attributes[i],
4461 CloneString(&value,attribute);
4467 if (LocaleCompare(keyword,"colors") == 0)
4469 quantize_info.number_colors=StringToLong(value);
4472 if (LocaleCompare(keyword,"colorspace") == 0)
4474 option=ParseCommandOption(MagickColorspaceOptions,
4477 ThrowMSLException(OptionError,
4478 "UnrecognizedColorspaceType",value);
4479 quantize_info.colorspace=(ColorspaceType) option;
4482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4489 if (LocaleCompare(keyword,"dither") == 0)
4491 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4494 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4496 quantize_info.dither=(MagickBooleanType) option;
4499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4506 if (LocaleCompare(keyword,"measure") == 0)
4508 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4511 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4513 quantize_info.measure_error=(MagickBooleanType) option;
4516 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4523 if (LocaleCompare(keyword,"treedepth") == 0)
4525 quantize_info.tree_depth=StringToLong(value);
4528 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4534 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4540 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4543 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4546 text[MaxTextExtent];
4557 draw_info=CloneDrawInfo(msl_info->image_info[n],
4558 msl_info->draw_info[n]);
4560 current=draw_info->affine;
4561 GetAffineMatrix(&affine);
4562 if (attributes != (const xmlChar **) NULL)
4563 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4565 keyword=(const char *) attributes[i++];
4566 attribute=InterpretImageProperties(msl_info->image_info[n],
4567 msl_info->attributes[n],(const char *) attributes[i],
4569 CloneString(&value,attribute);
4575 if (LocaleCompare(keyword,"affine") == 0)
4581 draw_info->affine.sx=StringToDouble(p,&p);
4584 draw_info->affine.rx=StringToDouble(p,&p);
4587 draw_info->affine.ry=StringToDouble(p,&p);
4590 draw_info->affine.sy=StringToDouble(p,&p);
4593 draw_info->affine.tx=StringToDouble(p,&p);
4596 draw_info->affine.ty=StringToDouble(p,&p);
4599 if (LocaleCompare(keyword,"align") == 0)
4601 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4604 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4606 draw_info->align=(AlignType) option;
4609 if (LocaleCompare(keyword,"antialias") == 0)
4611 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4614 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4616 draw_info->stroke_antialias=(MagickBooleanType) option;
4617 draw_info->text_antialias=(MagickBooleanType) option;
4620 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4627 if (LocaleCompare(keyword,"density") == 0)
4629 CloneString(&draw_info->density,value);
4632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4639 if (LocaleCompare(keyword,"encoding") == 0)
4641 CloneString(&draw_info->encoding,value);
4644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4651 if (LocaleCompare(keyword, "fill") == 0)
4653 (void) QueryColorCompliance(value,AllCompliance,
4654 &draw_info->fill,&exception);
4657 if (LocaleCompare(keyword,"family") == 0)
4659 CloneString(&draw_info->family,value);
4662 if (LocaleCompare(keyword,"font") == 0)
4664 CloneString(&draw_info->font,value);
4667 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4674 if (LocaleCompare(keyword,"geometry") == 0)
4676 flags=ParsePageGeometry(msl_info->image[n],value,
4677 &geometry,&exception);
4678 if ((flags & HeightValue) == 0)
4679 geometry.height=geometry.width;
4682 if (LocaleCompare(keyword,"gravity") == 0)
4684 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4687 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4689 draw_info->gravity=(GravityType) option;
4692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4699 if (LocaleCompare(keyword,"pointsize") == 0)
4701 draw_info->pointsize=StringToDouble(value,
4705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4712 if (LocaleCompare(keyword,"rotate") == 0)
4714 angle=StringToDouble(value,(char **) NULL);
4715 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4716 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4717 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4718 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4721 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4728 if (LocaleCompare(keyword,"scale") == 0)
4730 flags=ParseGeometry(value,&geometry_info);
4731 if ((flags & SigmaValue) == 0)
4732 geometry_info.sigma=1.0;
4733 affine.sx=geometry_info.rho;
4734 affine.sy=geometry_info.sigma;
4737 if (LocaleCompare(keyword,"skewX") == 0)
4739 angle=StringToDouble(value,(char **) NULL);
4740 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4743 if (LocaleCompare(keyword,"skewY") == 0)
4745 angle=StringToDouble(value,(char **) NULL);
4746 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4749 if (LocaleCompare(keyword,"stretch") == 0)
4751 option=ParseCommandOption(MagickStretchOptions,
4754 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4756 draw_info->stretch=(StretchType) option;
4759 if (LocaleCompare(keyword, "stroke") == 0)
4761 (void) QueryColorCompliance(value,AllCompliance,
4762 &draw_info->stroke,&exception);
4765 if (LocaleCompare(keyword,"strokewidth") == 0)
4767 draw_info->stroke_width=StringToLong(value);
4770 if (LocaleCompare(keyword,"style") == 0)
4772 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4775 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4777 draw_info->style=(StyleType) option;
4780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4787 if (LocaleCompare(keyword,"text") == 0)
4789 CloneString(&draw_info->text,value);
4792 if (LocaleCompare(keyword,"translate") == 0)
4794 flags=ParseGeometry(value,&geometry_info);
4795 if ((flags & SigmaValue) == 0)
4796 geometry_info.sigma=1.0;
4797 affine.tx=geometry_info.rho;
4798 affine.ty=geometry_info.sigma;
4801 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4808 if (LocaleCompare(keyword, "undercolor") == 0)
4810 (void) QueryColorCompliance(value,AllCompliance,
4811 &draw_info->undercolor,&exception);
4814 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4821 if (LocaleCompare(keyword,"weight") == 0)
4823 draw_info->weight=StringToLong(value);
4826 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4833 if (LocaleCompare(keyword,"x") == 0)
4835 geometry.x=StringToLong(value);
4838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4845 if (LocaleCompare(keyword,"y") == 0)
4847 geometry.y=StringToLong(value);
4850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4856 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4862 (void) FormatLocaleString(text,MaxTextExtent,
4863 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4864 geometry.height,(double) geometry.x,(double) geometry.y);
4865 CloneString(&draw_info->geometry,text);
4866 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4867 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4868 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4869 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4870 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4872 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4874 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4875 msl_info->exception);
4876 if (status != MagickFalse)
4881 image=msl_info->attributes[n];
4882 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4883 "%g",metrics.pixels_per_em.x);
4884 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4885 "%g",metrics.pixels_per_em.y);
4886 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4888 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4890 FormatImageProperty(image,"msl:font-metrics.width","%g",
4892 FormatImageProperty(image,"msl:font-metrics.height","%g",
4894 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4895 metrics.max_advance);
4896 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4898 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4900 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4902 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4904 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4906 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4909 draw_info=DestroyDrawInfo(draw_info);
4912 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4917 if (LocaleCompare((const char *) tag,"raise") == 0)
4925 if (msl_info->image[n] == (Image *) NULL)
4927 ThrowMSLException(OptionError,"NoImagesDefined",
4928 (const char *) tag);
4932 SetGeometry(msl_info->image[n],&geometry);
4933 if (attributes != (const xmlChar **) NULL)
4934 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4936 keyword=(const char *) attributes[i++];
4937 attribute=InterpretImageProperties(msl_info->image_info[n],
4938 msl_info->attributes[n],(const char *) attributes[i],
4940 CloneString(&value,attribute);
4946 if (LocaleCompare(keyword,"geometry") == 0)
4948 flags=ParsePageGeometry(msl_info->image[n],value,
4949 &geometry,&exception);
4950 if ((flags & HeightValue) == 0)
4951 geometry.height=geometry.width;
4954 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4961 if (LocaleCompare(keyword,"height") == 0)
4963 geometry.height=StringToLong(value);
4966 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4973 if (LocaleCompare(keyword,"raise") == 0)
4975 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4978 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4980 raise=(MagickBooleanType) option;
4983 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4990 if (LocaleCompare(keyword,"width") == 0)
4992 geometry.width=StringToLong(value);
4995 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5001 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5007 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5008 msl_info->exception);
5011 if (LocaleCompare((const char *) tag,"read") == 0)
5013 if (attributes == (const xmlChar **) NULL)
5015 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5017 keyword=(const char *) attributes[i++];
5018 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5019 msl_info->attributes[n],(const char *) attributes[i],&exception));
5025 if (LocaleCompare(keyword,"filename") == 0)
5030 (void) CopyMagickString(msl_info->image_info[n]->filename,
5031 value,MaxTextExtent);
5032 image=ReadImage(msl_info->image_info[n],&exception);
5033 CatchException(&exception);
5034 if (image == (Image *) NULL)
5036 AppendImageToList(&msl_info->image[n],image);
5039 (void) SetMSLAttributes(msl_info,keyword,value);
5044 (void) SetMSLAttributes(msl_info,keyword,value);
5051 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5059 if (msl_info->image[n] == (Image *) NULL)
5061 ThrowMSLException(OptionError,"NoImagesDefined",
5062 (const char *) tag);
5065 if (attributes != (const xmlChar **) NULL)
5066 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5068 keyword=(const char *) attributes[i++];
5069 attribute=InterpretImageProperties(msl_info->image_info[n],
5070 msl_info->attributes[n],(const char *) attributes[i],
5072 CloneString(&value,attribute);
5078 if (LocaleCompare(keyword,"geometry") == 0)
5080 flags=ParseGeometry(value,&geometry_info);
5081 if ((flags & SigmaValue) == 0)
5082 geometry_info.sigma=1.0;
5085 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5092 if (LocaleCompare(keyword,"radius") == 0)
5094 geometry_info.rho=StringToDouble(value,
5098 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5104 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5110 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5111 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5112 msl_info->exception);
5113 if (paint_image == (Image *) NULL)
5115 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5116 msl_info->image[n]=paint_image;
5119 else if (LocaleCompare((const char *) tag,"repage") == 0)
5121 /* init the values */
5122 width=msl_info->image[n]->page.width;
5123 height=msl_info->image[n]->page.height;
5124 x=msl_info->image[n]->page.x;
5125 y=msl_info->image[n]->page.y;
5127 if (msl_info->image[n] == (Image *) NULL)
5129 ThrowMSLException(OptionError,"NoImagesDefined",
5130 (const char *) tag);
5133 if (attributes == (const xmlChar **) NULL)
5135 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5137 keyword=(const char *) attributes[i++];
5138 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5139 msl_info->attributes[n],(const char *) attributes[i],&exception));
5145 if (LocaleCompare(keyword,"geometry") == 0)
5153 flags=ParseAbsoluteGeometry(value,&geometry);
5154 if ((flags & WidthValue) != 0)
5156 if ((flags & HeightValue) == 0)
5157 geometry.height=geometry.width;
5158 width=geometry.width;
5159 height=geometry.height;
5161 if ((flags & AspectValue) != 0)
5163 if ((flags & XValue) != 0)
5165 if ((flags & YValue) != 0)
5170 if ((flags & XValue) != 0)
5173 if ((width == 0) && (geometry.x > 0))
5174 width=msl_info->image[n]->columns+geometry.x;
5176 if ((flags & YValue) != 0)
5179 if ((height == 0) && (geometry.y > 0))
5180 height=msl_info->image[n]->rows+geometry.y;
5185 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5191 if (LocaleCompare(keyword,"height") == 0)
5193 height = StringToLong( value );
5196 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5202 if (LocaleCompare(keyword,"width") == 0)
5204 width = StringToLong( value );
5207 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5213 if (LocaleCompare(keyword,"x") == 0)
5215 x = StringToLong( value );
5218 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5224 if (LocaleCompare(keyword,"y") == 0)
5226 y = StringToLong( value );
5229 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5234 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5240 msl_info->image[n]->page.width=width;
5241 msl_info->image[n]->page.height=height;
5242 msl_info->image[n]->page.x=x;
5243 msl_info->image[n]->page.y=y;
5246 else if (LocaleCompare((const char *) tag,"resample") == 0)
5252 if (msl_info->image[n] == (Image *) NULL)
5254 ThrowMSLException(OptionError,"NoImagesDefined",
5255 (const char *) tag);
5258 if (attributes == (const xmlChar **) NULL)
5260 x_resolution=DefaultResolution;
5261 y_resolution=DefaultResolution;
5262 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5264 keyword=(const char *) attributes[i++];
5265 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5266 msl_info->attributes[n],(const char *) attributes[i],&exception));
5272 if (LocaleCompare(keyword,"geometry") == 0)
5277 flags=ParseGeometry(value,&geometry_info);
5278 if ((flags & SigmaValue) == 0)
5279 geometry_info.sigma*=geometry_info.rho;
5280 x_resolution=geometry_info.rho;
5281 y_resolution=geometry_info.sigma;
5284 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5290 if (LocaleCompare(keyword,"x-resolution") == 0)
5292 x_resolution=StringToDouble(value,(char **) NULL);
5295 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5301 if (LocaleCompare(keyword,"y-resolution") == 0)
5303 y_resolution=StringToDouble(value,(char **) NULL);
5306 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5311 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5327 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5329 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5330 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5331 msl_info->image[n]->resolution.x))+0.5);
5332 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5333 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5334 msl_info->image[n]->resolution.y))+0.5);
5335 resample_image=ResizeImage(msl_info->image[n],width,height,
5336 msl_info->image[n]->filter,msl_info->exception);
5337 if (resample_image == (Image *) NULL)
5339 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5340 msl_info->image[n]=resample_image;
5344 if (LocaleCompare((const char *) tag,"resize") == 0)
5355 if (msl_info->image[n] == (Image *) NULL)
5357 ThrowMSLException(OptionError,"NoImagesDefined",
5358 (const char *) tag);
5361 filter=UndefinedFilter;
5362 if (attributes != (const xmlChar **) NULL)
5363 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5365 keyword=(const char *) attributes[i++];
5366 attribute=InterpretImageProperties(msl_info->image_info[n],
5367 msl_info->attributes[n],(const char *) attributes[i],
5369 CloneString(&value,attribute);
5375 if (LocaleCompare(keyword,"filter") == 0)
5377 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5380 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5382 filter=(FilterTypes) option;
5385 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5392 if (LocaleCompare(keyword,"geometry") == 0)
5394 flags=ParseRegionGeometry(msl_info->image[n],value,
5395 &geometry,&exception);
5398 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5405 if (LocaleCompare(keyword,"height") == 0)
5407 geometry.height=StringToUnsignedLong(value);
5410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5417 if (LocaleCompare(keyword,"width") == 0)
5419 geometry.width=StringToLong(value);
5422 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5428 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5434 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5435 geometry.height,filter,msl_info->exception);
5436 if (resize_image == (Image *) NULL)
5438 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5439 msl_info->image[n]=resize_image;
5442 if (LocaleCompare((const char *) tag,"roll") == 0)
5450 if (msl_info->image[n] == (Image *) NULL)
5452 ThrowMSLException(OptionError,"NoImagesDefined",
5453 (const char *) tag);
5456 SetGeometry(msl_info->image[n],&geometry);
5457 if (attributes != (const xmlChar **) NULL)
5458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5460 keyword=(const char *) attributes[i++];
5461 attribute=InterpretImageProperties(msl_info->image_info[n],
5462 msl_info->attributes[n],(const char *) attributes[i],
5464 CloneString(&value,attribute);
5470 if (LocaleCompare(keyword,"geometry") == 0)
5472 flags=ParsePageGeometry(msl_info->image[n],value,
5473 &geometry,&exception);
5474 if ((flags & HeightValue) == 0)
5475 geometry.height=geometry.width;
5478 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5485 if (LocaleCompare(keyword,"x") == 0)
5487 geometry.x=StringToLong(value);
5490 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5497 if (LocaleCompare(keyword,"y") == 0)
5499 geometry.y=StringToLong(value);
5502 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5508 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5514 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5515 msl_info->exception);
5516 if (roll_image == (Image *) NULL)
5518 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5519 msl_info->image[n]=roll_image;
5522 else if (LocaleCompare((const char *) tag,"roll") == 0)
5524 /* init the values */
5525 width=msl_info->image[n]->columns;
5526 height=msl_info->image[n]->rows;
5529 if (msl_info->image[n] == (Image *) NULL)
5531 ThrowMSLException(OptionError,"NoImagesDefined",
5532 (const char *) tag);
5535 if (attributes == (const xmlChar **) NULL)
5537 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5539 keyword=(const char *) attributes[i++];
5540 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5541 msl_info->attributes[n],(const char *) attributes[i],&exception));
5547 if (LocaleCompare(keyword,"geometry") == 0)
5549 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5552 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5558 if (LocaleCompare(keyword,"x") == 0)
5560 x = StringToLong( value );
5563 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5569 if (LocaleCompare(keyword,"y") == 0)
5571 y = StringToLong( value );
5574 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5579 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5592 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5593 if (newImage == (Image *) NULL)
5595 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5596 msl_info->image[n]=newImage;
5601 if (LocaleCompare((const char *) tag,"rotate") == 0)
5609 if (msl_info->image[n] == (Image *) NULL)
5611 ThrowMSLException(OptionError,"NoImagesDefined",
5612 (const char *) tag);
5615 if (attributes != (const xmlChar **) NULL)
5616 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5618 keyword=(const char *) attributes[i++];
5619 attribute=InterpretImageProperties(msl_info->image_info[n],
5620 msl_info->attributes[n],(const char *) attributes[i],
5622 CloneString(&value,attribute);
5628 if (LocaleCompare(keyword,"degrees") == 0)
5630 geometry_info.rho=StringToDouble(value,
5634 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5641 if (LocaleCompare(keyword,"geometry") == 0)
5643 flags=ParseGeometry(value,&geometry_info);
5644 if ((flags & SigmaValue) == 0)
5645 geometry_info.sigma=1.0;
5648 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5660 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5661 msl_info->exception);
5662 if (rotate_image == (Image *) NULL)
5664 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5665 msl_info->image[n]=rotate_image;
5668 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5670 /* init the values */
5673 if (msl_info->image[n] == (Image *) NULL)
5675 ThrowMSLException(OptionError,"NoImagesDefined",
5676 (const char *) tag);
5679 if (attributes == (const xmlChar **) NULL)
5681 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5683 keyword=(const char *) attributes[i++];
5684 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5685 msl_info->attributes[n],(const char *) attributes[i],&exception));
5691 if (LocaleCompare(keyword,"degrees") == 0)
5693 degrees = StringToDouble(value,(char **) NULL);
5696 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5701 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5714 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5715 if (newImage == (Image *) NULL)
5717 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5718 msl_info->image[n]=newImage;
5723 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5728 if (LocaleCompare((const char *) tag,"sample") == 0)
5736 if (msl_info->image[n] == (Image *) NULL)
5738 ThrowMSLException(OptionError,"NoImagesDefined",
5739 (const char *) tag);
5742 if (attributes != (const xmlChar **) NULL)
5743 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5745 keyword=(const char *) attributes[i++];
5746 attribute=InterpretImageProperties(msl_info->image_info[n],
5747 msl_info->attributes[n],(const char *) attributes[i],
5749 CloneString(&value,attribute);
5755 if (LocaleCompare(keyword,"geometry") == 0)
5757 flags=ParseRegionGeometry(msl_info->image[n],value,
5758 &geometry,&exception);
5761 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5768 if (LocaleCompare(keyword,"height") == 0)
5770 geometry.height=StringToUnsignedLong(value);
5773 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5780 if (LocaleCompare(keyword,"width") == 0)
5782 geometry.width=StringToLong(value);
5785 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5791 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5797 sample_image=SampleImage(msl_info->image[n],geometry.width,
5798 geometry.height,msl_info->exception);
5799 if (sample_image == (Image *) NULL)
5801 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5802 msl_info->image[n]=sample_image;
5805 if (LocaleCompare((const char *) tag,"scale") == 0)
5813 if (msl_info->image[n] == (Image *) NULL)
5815 ThrowMSLException(OptionError,"NoImagesDefined",
5816 (const char *) tag);
5819 if (attributes != (const xmlChar **) NULL)
5820 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5822 keyword=(const char *) attributes[i++];
5823 attribute=InterpretImageProperties(msl_info->image_info[n],
5824 msl_info->attributes[n],(const char *) attributes[i],
5826 CloneString(&value,attribute);
5832 if (LocaleCompare(keyword,"geometry") == 0)
5834 flags=ParseRegionGeometry(msl_info->image[n],value,
5835 &geometry,&exception);
5838 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5845 if (LocaleCompare(keyword,"height") == 0)
5847 geometry.height=StringToUnsignedLong(value);
5850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5857 if (LocaleCompare(keyword,"width") == 0)
5859 geometry.width=StringToLong(value);
5862 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5868 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5874 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5875 geometry.height,msl_info->exception);
5876 if (scale_image == (Image *) NULL)
5878 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5879 msl_info->image[n]=scale_image;
5882 if (LocaleCompare((const char *) tag,"segment") == 0)
5893 if (msl_info->image[n] == (Image *) NULL)
5895 ThrowMSLException(OptionError,"NoImagesDefined",
5896 (const char *) tag);
5899 geometry_info.rho=1.0;
5900 geometry_info.sigma=1.5;
5901 colorspace=RGBColorspace;
5902 verbose=MagickFalse;
5903 if (attributes != (const xmlChar **) NULL)
5904 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5906 keyword=(const char *) attributes[i++];
5907 attribute=InterpretImageProperties(msl_info->image_info[n],
5908 msl_info->attributes[n],(const char *) attributes[i],
5910 CloneString(&value,attribute);
5916 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5918 geometry_info.rho=StringToDouble(value,
5922 if (LocaleCompare(keyword,"colorspace") == 0)
5924 option=ParseCommandOption(MagickColorspaceOptions,
5927 ThrowMSLException(OptionError,
5928 "UnrecognizedColorspaceType",value);
5929 colorspace=(ColorspaceType) option;
5932 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5939 if (LocaleCompare(keyword,"geometry") == 0)
5941 flags=ParseGeometry(value,&geometry_info);
5942 if ((flags & SigmaValue) == 0)
5943 geometry_info.sigma=1.5;
5946 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5953 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5955 geometry_info.sigma=StringToDouble(value,
5959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5971 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5972 geometry_info.rho,geometry_info.sigma,&exception);
5975 else if (LocaleCompare((const char *) tag, "set") == 0)
5977 if (msl_info->image[n] == (Image *) NULL)
5979 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
5983 if (attributes == (const xmlChar **) NULL)
5985 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5987 keyword=(const char *) attributes[i++];
5988 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5989 msl_info->attributes[n],(const char *) attributes[i],&exception));
5995 if (LocaleCompare(keyword,"clip-mask") == 0)
5997 for (j=0; j < msl_info->n; j++)
6002 property=GetImageProperty(msl_info->attributes[j],"id",
6004 if (LocaleCompare(property,value) == 0)
6006 SetImageMask(msl_info->image[n],msl_info->image[j],
6013 if (LocaleCompare(keyword,"clip-path") == 0)
6015 for (j=0; j < msl_info->n; j++)
6020 property=GetImageProperty(msl_info->attributes[j],"id",
6022 if (LocaleCompare(property,value) == 0)
6024 SetImageMask(msl_info->image[n],msl_info->image[j],
6031 if (LocaleCompare(keyword,"colorspace") == 0)
6036 colorspace=(ColorspaceType) ParseCommandOption(
6037 MagickColorspaceOptions,MagickFalse,value);
6039 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6041 (void) TransformImageColorspace(msl_info->image[n],
6042 (ColorspaceType) colorspace,&exception);
6045 (void) SetMSLAttributes(msl_info,keyword,value);
6046 (void) SetImageProperty(msl_info->image[n],keyword,value,
6053 if (LocaleCompare(keyword,"density") == 0)
6055 flags=ParseGeometry(value,&geometry_info);
6056 msl_info->image[n]->resolution.x=geometry_info.rho;
6057 msl_info->image[n]->resolution.y=geometry_info.sigma;
6058 if ((flags & SigmaValue) == 0)
6059 msl_info->image[n]->resolution.y=
6060 msl_info->image[n]->resolution.x;
6063 (void) SetMSLAttributes(msl_info,keyword,value);
6064 (void) SetImageProperty(msl_info->image[n],keyword,value,
6071 if (LocaleCompare(keyword, "opacity") == 0)
6073 ssize_t opac = OpaqueAlpha,
6074 len = (ssize_t) strlen( value );
6076 if (value[len-1] == '%') {
6078 (void) CopyMagickString(tmp,value,len);
6079 opac = StringToLong( tmp );
6080 opac = (int)(QuantumRange * ((float)opac/100));
6082 opac = StringToLong( value );
6083 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6087 (void) SetMSLAttributes(msl_info,keyword,value);
6088 (void) SetImageProperty(msl_info->image[n],keyword,value,
6089 msl_info->exception);
6095 if (LocaleCompare(keyword, "page") == 0)
6098 page[MaxTextExtent];
6109 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6110 image_option=GetImageOption(msl_info->image_info[n],"page");
6111 if (image_option != (const char *) NULL)
6112 flags=ParseAbsoluteGeometry(image_option,&geometry);
6113 flags=ParseAbsoluteGeometry(value,&geometry);
6114 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6115 (double) geometry.width,(double) geometry.height);
6116 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6117 (void) FormatLocaleString(page,MaxTextExtent,
6118 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6119 (double) geometry.height,(double) geometry.x,(double)
6121 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6122 msl_info->image_info[n]->page=GetPageGeometry(page);
6125 (void) SetMSLAttributes(msl_info,keyword,value);
6126 (void) SetImageProperty(msl_info->image[n],keyword,value,
6127 msl_info->exception);
6132 (void) SetMSLAttributes(msl_info,keyword,value);
6133 (void) SetImageProperty(msl_info->image[n],keyword,value,
6134 msl_info->exception);
6141 if (LocaleCompare((const char *) tag,"shade") == 0)
6152 if (msl_info->image[n] == (Image *) NULL)
6154 ThrowMSLException(OptionError,"NoImagesDefined",
6155 (const char *) tag);
6159 if (attributes != (const xmlChar **) NULL)
6160 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6162 keyword=(const char *) attributes[i++];
6163 attribute=InterpretImageProperties(msl_info->image_info[n],
6164 msl_info->attributes[n],(const char *) attributes[i],
6166 CloneString(&value,attribute);
6172 if (LocaleCompare(keyword,"azimuth") == 0)
6174 geometry_info.rho=StringToDouble(value,
6178 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6185 if (LocaleCompare(keyword,"elevation") == 0)
6187 geometry_info.sigma=StringToDouble(value,
6191 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6198 if (LocaleCompare(keyword,"geometry") == 0)
6200 flags=ParseGeometry(value,&geometry_info);
6201 if ((flags & SigmaValue) == 0)
6202 geometry_info.sigma=1.0;
6205 if (LocaleCompare(keyword,"gray") == 0)
6207 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6210 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6212 gray=(MagickBooleanType) option;
6215 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6227 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6228 geometry_info.sigma,msl_info->exception);
6229 if (shade_image == (Image *) NULL)
6231 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6232 msl_info->image[n]=shade_image;
6235 if (LocaleCompare((const char *) tag,"shadow") == 0)
6243 if (msl_info->image[n] == (Image *) NULL)
6245 ThrowMSLException(OptionError,"NoImagesDefined",
6246 (const char *) tag);
6249 if (attributes != (const xmlChar **) NULL)
6250 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6252 keyword=(const char *) attributes[i++];
6253 attribute=InterpretImageProperties(msl_info->image_info[n],
6254 msl_info->attributes[n],(const char *) attributes[i],
6256 CloneString(&value,attribute);
6262 if (LocaleCompare(keyword,"geometry") == 0)
6264 flags=ParseGeometry(value,&geometry_info);
6265 if ((flags & SigmaValue) == 0)
6266 geometry_info.sigma=1.0;
6269 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6276 if (LocaleCompare(keyword,"opacity") == 0)
6278 geometry_info.rho=StringToLong(value);
6281 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6288 if (LocaleCompare(keyword,"sigma") == 0)
6290 geometry_info.sigma=StringToLong(value);
6298 if (LocaleCompare(keyword,"x") == 0)
6300 geometry_info.xi=StringToDouble(value,
6304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6311 if (LocaleCompare(keyword,"y") == 0)
6313 geometry_info.psi=StringToLong(value);
6316 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6322 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6328 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6329 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6330 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6331 if (shadow_image == (Image *) NULL)
6333 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6334 msl_info->image[n]=shadow_image;
6337 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6343 if (msl_info->image[n] == (Image *) NULL)
6345 ThrowMSLException(OptionError,"NoImagesDefined",
6346 (const char *) tag);
6350 NOTE: sharpen can have no attributes, since we use all the defaults!
6352 if (attributes != (const xmlChar **) NULL)
6354 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6356 keyword=(const char *) attributes[i++];
6357 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6358 msl_info->attributes[n],(const char *) attributes[i],&exception));
6364 if (LocaleCompare(keyword, "radius") == 0)
6366 radius = StringToDouble(value,(char **) NULL);
6369 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6375 if (LocaleCompare(keyword,"sigma") == 0)
6377 sigma = StringToLong( value );
6380 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6385 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6399 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6400 msl_info->exception);
6401 if (newImage == (Image *) NULL)
6403 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6404 msl_info->image[n]=newImage;
6408 else if (LocaleCompare((const char *) tag,"shave") == 0)
6410 /* init the values */
6414 if (msl_info->image[n] == (Image *) NULL)
6416 ThrowMSLException(OptionError,"NoImagesDefined",
6417 (const char *) tag);
6420 if (attributes == (const xmlChar **) NULL)
6422 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6424 keyword=(const char *) attributes[i++];
6425 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6426 msl_info->attributes[n],(const char *) attributes[i],&exception));
6432 if (LocaleCompare(keyword,"geometry") == 0)
6434 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6437 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6443 if (LocaleCompare(keyword,"height") == 0)
6445 height = StringToLong( value );
6448 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6454 if (LocaleCompare(keyword,"width") == 0)
6456 width = StringToLong( value );
6459 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6464 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6479 rectInfo.height = height;
6480 rectInfo.width = width;
6485 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6486 msl_info->exception);
6487 if (newImage == (Image *) NULL)
6489 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6490 msl_info->image[n]=newImage;
6495 if (LocaleCompare((const char *) tag,"shear") == 0)
6503 if (msl_info->image[n] == (Image *) NULL)
6505 ThrowMSLException(OptionError,"NoImagesDefined",
6506 (const char *) tag);
6509 if (attributes != (const xmlChar **) NULL)
6510 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6512 keyword=(const char *) attributes[i++];
6513 attribute=InterpretImageProperties(msl_info->image_info[n],
6514 msl_info->attributes[n],(const char *) attributes[i],
6516 CloneString(&value,attribute);
6522 if (LocaleCompare(keyword, "fill") == 0)
6524 (void) QueryColorCompliance(value,AllCompliance,
6525 &msl_info->image[n]->background_color,&exception);
6528 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6535 if (LocaleCompare(keyword,"geometry") == 0)
6537 flags=ParseGeometry(value,&geometry_info);
6538 if ((flags & SigmaValue) == 0)
6539 geometry_info.sigma=1.0;
6542 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6549 if (LocaleCompare(keyword,"x") == 0)
6551 geometry_info.rho=StringToDouble(value,
6555 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6562 if (LocaleCompare(keyword,"y") == 0)
6564 geometry_info.sigma=StringToLong(value);
6567 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6573 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6579 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6580 geometry_info.sigma,msl_info->exception);
6581 if (shear_image == (Image *) NULL)
6583 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6584 msl_info->image[n]=shear_image;
6587 if (LocaleCompare((const char *) tag,"signature") == 0)
6592 if (msl_info->image[n] == (Image *) NULL)
6594 ThrowMSLException(OptionError,"NoImagesDefined",
6595 (const char *) tag);
6598 if (attributes != (const xmlChar **) NULL)
6599 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6601 keyword=(const char *) attributes[i++];
6602 attribute=InterpretImageProperties(msl_info->image_info[n],
6603 msl_info->attributes[n],(const char *) attributes[i],
6605 CloneString(&value,attribute);
6610 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6616 (void) SignatureImage(msl_info->image[n],&exception);
6619 if (LocaleCompare((const char *) tag,"solarize") == 0)
6624 if (msl_info->image[n] == (Image *) NULL)
6626 ThrowMSLException(OptionError,"NoImagesDefined",
6627 (const char *) tag);
6630 geometry_info.rho=QuantumRange/2.0;
6631 if (attributes != (const xmlChar **) NULL)
6632 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6634 keyword=(const char *) attributes[i++];
6635 attribute=InterpretImageProperties(msl_info->image_info[n],
6636 msl_info->attributes[n],(const char *) attributes[i],
6638 CloneString(&value,attribute);
6644 if (LocaleCompare(keyword,"geometry") == 0)
6646 flags=ParseGeometry(value,&geometry_info);
6649 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6656 if (LocaleCompare(keyword,"threshold") == 0)
6658 geometry_info.rho=StringToDouble(value,
6662 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6668 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6674 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6675 msl_info->exception);
6678 if (LocaleCompare((const char *) tag,"spread") == 0)
6686 if (msl_info->image[n] == (Image *) NULL)
6688 ThrowMSLException(OptionError,"NoImagesDefined",
6689 (const char *) tag);
6692 if (attributes != (const xmlChar **) NULL)
6693 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6695 keyword=(const char *) attributes[i++];
6696 attribute=InterpretImageProperties(msl_info->image_info[n],
6697 msl_info->attributes[n],(const char *) attributes[i],
6699 CloneString(&value,attribute);
6705 if (LocaleCompare(keyword,"geometry") == 0)
6707 flags=ParseGeometry(value,&geometry_info);
6708 if ((flags & SigmaValue) == 0)
6709 geometry_info.sigma=1.0;
6712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6719 if (LocaleCompare(keyword,"radius") == 0)
6721 geometry_info.rho=StringToDouble(value,
6725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6737 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6738 msl_info->image[n]->interpolate,msl_info->exception);
6739 if (spread_image == (Image *) NULL)
6741 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6742 msl_info->image[n]=spread_image;
6745 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6748 watermark = (Image*)NULL;
6750 if (msl_info->image[n] == (Image *) NULL)
6752 ThrowMSLException(OptionError,"NoImagesDefined",
6753 (const char *) tag);
6756 if (attributes == (const xmlChar **) NULL)
6758 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6760 keyword=(const char *) attributes[i++];
6761 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6762 msl_info->attributes[n],(const char *) attributes[i],&exception));
6768 if (LocaleCompare(keyword,"image") == 0)
6770 for (j=0; j<msl_info->n;j++)
6773 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6775 if (theAttr && LocaleCompare(theAttr, value) == 0)
6777 watermark = msl_info->image[j];
6783 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6788 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6797 if ( watermark != (Image*) NULL )
6802 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6803 if (newImage == (Image *) NULL)
6805 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6806 msl_info->image[n]=newImage;
6809 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6811 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6814 stereoImage = (Image*)NULL;
6816 if (msl_info->image[n] == (Image *) NULL)
6818 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6821 if (attributes == (const xmlChar **) NULL)
6823 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6825 keyword=(const char *) attributes[i++];
6826 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6827 msl_info->attributes[n],(const char *) attributes[i],&exception));
6833 if (LocaleCompare(keyword,"image") == 0)
6835 for (j=0; j<msl_info->n;j++)
6838 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6840 if (theAttr && LocaleCompare(theAttr, value) == 0)
6842 stereoImage = msl_info->image[j];
6848 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6853 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6862 if ( stereoImage != (Image*) NULL )
6867 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6868 if (newImage == (Image *) NULL)
6870 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6871 msl_info->image[n]=newImage;
6874 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6876 if (LocaleCompare((const char *) tag,"swap") == 0)
6887 if (msl_info->image[n] == (Image *) NULL)
6889 ThrowMSLException(OptionError,"NoImagesDefined",
6890 (const char *) tag);
6895 if (attributes != (const xmlChar **) NULL)
6896 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6898 keyword=(const char *) attributes[i++];
6899 attribute=InterpretImageProperties(msl_info->image_info[n],
6900 msl_info->attributes[n],(const char *) attributes[i],
6902 CloneString(&value,attribute);
6908 if (LocaleCompare(keyword,"indexes") == 0)
6910 flags=ParseGeometry(value,&geometry_info);
6911 index=(ssize_t) geometry_info.rho;
6912 if ((flags & SigmaValue) == 0)
6913 swap_index=(ssize_t) geometry_info.sigma;
6916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6931 p=GetImageFromList(msl_info->image[n],index);
6932 q=GetImageFromList(msl_info->image[n],swap_index);
6933 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6935 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6938 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6939 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6940 msl_info->exception));
6941 ReplaceImageInList(&q,swap);
6942 msl_info->image[n]=GetFirstImageInList(q);
6945 if (LocaleCompare((const char *) tag,"swirl") == 0)
6953 if (msl_info->image[n] == (Image *) NULL)
6955 ThrowMSLException(OptionError,"NoImagesDefined",
6956 (const char *) tag);
6959 if (attributes != (const xmlChar **) NULL)
6960 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6962 keyword=(const char *) attributes[i++];
6963 attribute=InterpretImageProperties(msl_info->image_info[n],
6964 msl_info->attributes[n],(const char *) attributes[i],
6966 CloneString(&value,attribute);
6972 if (LocaleCompare(keyword,"degrees") == 0)
6974 geometry_info.rho=StringToDouble(value,
6978 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6985 if (LocaleCompare(keyword,"geometry") == 0)
6987 flags=ParseGeometry(value,&geometry_info);
6988 if ((flags & SigmaValue) == 0)
6989 geometry_info.sigma=1.0;
6992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6998 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7004 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7005 msl_info->image[n]->interpolate,msl_info->exception);
7006 if (swirl_image == (Image *) NULL)
7008 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7009 msl_info->image[n]=swirl_image;
7012 if (LocaleCompare((const char *) tag,"sync") == 0)
7017 if (msl_info->image[n] == (Image *) NULL)
7019 ThrowMSLException(OptionError,"NoImagesDefined",
7020 (const char *) tag);
7023 if (attributes != (const xmlChar **) NULL)
7024 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7026 keyword=(const char *) attributes[i++];
7027 attribute=InterpretImageProperties(msl_info->image_info[n],
7028 msl_info->attributes[n],(const char *) attributes[i],
7030 CloneString(&value,attribute);
7035 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7041 (void) SyncImage(msl_info->image[n],&exception);
7044 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7049 if (LocaleCompare((const char *) tag,"map") == 0)
7057 if (msl_info->image[n] == (Image *) NULL)
7059 ThrowMSLException(OptionError,"NoImagesDefined",
7060 (const char *) tag);
7063 texture_image=NewImageList();
7064 if (attributes != (const xmlChar **) NULL)
7065 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7067 keyword=(const char *) attributes[i++];
7068 attribute=InterpretImageProperties(msl_info->image_info[n],
7069 msl_info->attributes[n],(const char *) attributes[i],
7071 CloneString(&value,attribute);
7077 if (LocaleCompare(keyword,"image") == 0)
7078 for (j=0; j < msl_info->n; j++)
7083 attribute=GetImageProperty(msl_info->attributes[j],"id",
7085 if ((attribute != (const char *) NULL) &&
7086 (LocaleCompare(attribute,value) == 0))
7088 texture_image=CloneImage(msl_info->image[j],0,0,
7089 MagickFalse,&exception);
7097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7103 (void) TextureImage(msl_info->image[n],texture_image,&exception);
7104 texture_image=DestroyImage(texture_image);
7107 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7109 /* init the values */
7110 double threshold = 0;
7112 if (msl_info->image[n] == (Image *) NULL)
7114 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7117 if (attributes == (const xmlChar **) NULL)
7119 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7121 keyword=(const char *) attributes[i++];
7122 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7123 msl_info->attributes[n],(const char *) attributes[i],&exception));
7129 if (LocaleCompare(keyword,"threshold") == 0)
7131 threshold = StringToDouble(value,(char **) NULL);
7134 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7139 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7149 BilevelImage(msl_info->image[n],threshold,&exception);
7153 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7155 if (msl_info->image[n] == (Image *) NULL)
7157 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7160 if (attributes == (const xmlChar **) NULL)
7162 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7164 keyword=(const char *) attributes[i++];
7165 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7166 msl_info->attributes[n],(const char *) attributes[i],&exception));
7172 if (LocaleCompare(keyword,"color") == 0)
7177 (void) QueryColorCompliance(value,AllCompliance,&target,
7179 (void) TransparentPaintImage(msl_info->image[n],&target,
7180 TransparentAlpha,MagickFalse,msl_info->exception);
7183 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7188 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7195 else if (LocaleCompare((const char *) tag, "trim") == 0)
7197 if (msl_info->image[n] == (Image *) NULL)
7199 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7203 /* no attributes here */
7205 /* process the image */
7212 /* all zeros on a crop == trim edges! */
7213 rectInfo.height = rectInfo.width = 0;
7214 rectInfo.x = rectInfo.y = 0;
7216 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7217 if (newImage == (Image *) NULL)
7219 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7220 msl_info->image[n]=newImage;
7224 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7229 if (LocaleCompare((const char *) tag,"write") == 0)
7231 if (msl_info->image[n] == (Image *) NULL)
7233 ThrowMSLException(OptionError,"NoImagesDefined",
7234 (const char *) tag);
7237 if (attributes == (const xmlChar **) NULL)
7239 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7241 keyword=(const char *) attributes[i++];
7242 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7243 msl_info->attributes[n],(const char *) attributes[i],&exception));
7249 if (LocaleCompare(keyword,"filename") == 0)
7251 (void) CopyMagickString(msl_info->image[n]->filename,value,
7255 (void) SetMSLAttributes(msl_info,keyword,value);
7259 (void) SetMSLAttributes(msl_info,keyword,value);
7267 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7268 msl_info->exception);
7272 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7276 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7280 if ( value != NULL )
7281 value=DestroyString(value);
7282 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7285 static void MSLEndElement(void *context,const xmlChar *tag)
7294 Called when the end of an element has been detected.
7296 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7298 msl_info=(MSLInfo *) context;
7305 if (LocaleCompare((const char *) tag,"comment") == 0 )
7307 (void) DeleteImageProperty(msl_info->image[n],"comment");
7308 if (msl_info->content == (char *) NULL)
7310 StripString(msl_info->content);
7311 (void) SetImageProperty(msl_info->image[n],"comment",
7312 msl_info->content,msl_info->exception);
7320 if (LocaleCompare((const char *) tag, "group") == 0 )
7322 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7324 ssize_t i = (ssize_t)
7325 (msl_info->group_info[msl_info->number_groups-1].numImages);
7328 if (msl_info->image[msl_info->n] != (Image *) NULL)
7329 msl_info->image[msl_info->n]=DestroyImage(
7330 msl_info->image[msl_info->n]);
7331 msl_info->attributes[msl_info->n]=DestroyImage(
7332 msl_info->attributes[msl_info->n]);
7333 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7334 msl_info->image_info[msl_info->n]);
7338 msl_info->number_groups--;
7345 if (LocaleCompare((const char *) tag, "image") == 0)
7346 MSLPopImage(msl_info);
7352 if (LocaleCompare((const char *) tag,"label") == 0 )
7354 (void) DeleteImageProperty(msl_info->image[n],"label");
7355 if (msl_info->content == (char *) NULL)
7357 StripString(msl_info->content);
7358 (void) SetImageProperty(msl_info->image[n],"label",
7359 msl_info->content,msl_info->exception);
7367 if (LocaleCompare((const char *) tag, "msl") == 0 )
7370 This our base element.
7371 at the moment we don't do anything special
7372 but someday we might!
7380 if (msl_info->content != (char *) NULL)
7381 msl_info->content=DestroyString(msl_info->content);
7384 static void MSLCharacters(void *context,const xmlChar *c,int length)
7396 Receiving some characters from the parser.
7398 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7399 " SAX.characters(%s,%d)",c,length);
7400 msl_info=(MSLInfo *) context;
7401 if (msl_info->content != (char *) NULL)
7402 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7403 strlen(msl_info->content)+length+MaxTextExtent,
7404 sizeof(*msl_info->content));
7407 msl_info->content=(char *) NULL;
7408 if (~length >= (MaxTextExtent-1))
7409 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7410 sizeof(*msl_info->content));
7411 if (msl_info->content != (char *) NULL)
7412 *msl_info->content='\0';
7414 if (msl_info->content == (char *) NULL)
7416 p=msl_info->content+strlen(msl_info->content);
7417 for (i=0; i < length; i++)
7422 static void MSLReference(void *context,const xmlChar *name)
7431 Called when an entity reference is detected.
7433 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7434 " SAX.reference(%s)",name);
7435 msl_info=(MSLInfo *) context;
7436 parser=msl_info->parser;
7438 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7440 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7443 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7449 Receiving some ignorable whitespaces from the parser.
7451 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7452 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7453 msl_info=(MSLInfo *) context;
7457 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7458 const xmlChar *data)
7464 A processing instruction has been parsed.
7466 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7467 " SAX.processingInstruction(%s, %s)",
7469 msl_info=(MSLInfo *) context;
7473 static void MSLComment(void *context,const xmlChar *value)
7479 A comment has been parsed.
7481 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7482 " SAX.comment(%s)",value);
7483 msl_info=(MSLInfo *) context;
7487 static void MSLWarning(void *context,const char *format,...)
7491 reason[MaxTextExtent];
7500 Display and format a warning messages, gives file, line, position and
7503 va_start(operands,format);
7504 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7505 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7506 msl_info=(MSLInfo *) context;
7508 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7509 (void) vsprintf(reason,format,operands);
7511 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7513 message=GetExceptionMessage(errno);
7514 ThrowMSLException(CoderError,reason,message);
7515 message=DestroyString(message);
7519 static void MSLError(void *context,const char *format,...)
7522 reason[MaxTextExtent];
7531 Display and format a error formats, gives file, line, position and
7534 va_start(operands,format);
7535 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7536 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7537 msl_info=(MSLInfo *) context;
7539 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7540 (void) vsprintf(reason,format,operands);
7542 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7544 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7548 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7560 Called when a pcdata block has been parsed.
7562 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7563 " SAX.pcdata(%s, %d)",value,length);
7564 msl_info=(MSLInfo *) context;
7566 parser=msl_info->parser;
7567 child=xmlGetLastChild(parser->node);
7568 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7570 xmlTextConcat(child,value,length);
7573 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7576 static void MSLExternalSubset(void *context,const xmlChar *name,
7577 const xmlChar *external_id,const xmlChar *system_id)
7592 Does this document has an external subset?
7594 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7595 " SAX.externalSubset(%s %s %s)",name,
7596 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7597 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7598 msl_info=(MSLInfo *) context;
7600 parser=msl_info->parser;
7601 if (((external_id == NULL) && (system_id == NULL)) ||
7602 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7603 (msl_info->document == 0)))
7605 input=MSLResolveEntity(context,external_id,system_id);
7608 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7609 parser_context=(*parser);
7610 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7611 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7613 parser->errNo=XML_ERR_NO_MEMORY;
7614 parser->input=parser_context.input;
7615 parser->inputNr=parser_context.inputNr;
7616 parser->inputMax=parser_context.inputMax;
7617 parser->inputTab=parser_context.inputTab;
7623 xmlPushInput(parser,input);
7624 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7625 if (input->filename == (char *) NULL)
7626 input->filename=(char *) xmlStrdup(system_id);
7629 input->base=parser->input->cur;
7630 input->cur=parser->input->cur;
7632 xmlParseExternalSubset(parser,external_id,system_id);
7633 while (parser->inputNr > 1)
7634 (void) xmlPopInput(parser);
7635 xmlFreeInputStream(parser->input);
7636 xmlFree(parser->inputTab);
7637 parser->input=parser_context.input;
7638 parser->inputNr=parser_context.inputNr;
7639 parser->inputMax=parser_context.inputMax;
7640 parser->inputTab=parser_context.inputTab;
7643 #if defined(__cplusplus) || defined(c_plusplus)
7647 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7648 ExceptionInfo *exception)
7651 message[MaxTextExtent];
7674 assert(image_info != (const ImageInfo *) NULL);
7675 assert(image_info->signature == MagickSignature);
7676 if (image_info->debug != MagickFalse)
7677 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7678 image_info->filename);
7679 assert(image != (Image **) NULL);
7680 msl_image=AcquireImage(image_info,exception);
7681 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7682 if (status == MagickFalse)
7684 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7685 msl_image->filename);
7686 msl_image=DestroyImageList(msl_image);
7687 return(MagickFalse);
7689 msl_image->columns=1;
7694 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7695 msl_info.exception=exception;
7696 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7697 sizeof(*msl_info.image_info));
7698 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7699 sizeof(*msl_info.draw_info));
7700 /* top of the stack is the MSL file itself */
7701 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7702 msl_info.attributes=(Image **) AcquireMagickMemory(
7703 sizeof(*msl_info.attributes));
7704 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7705 sizeof(*msl_info.group_info));
7706 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7707 (msl_info.image == (Image **) NULL) ||
7708 (msl_info.attributes == (Image **) NULL) ||
7709 (msl_info.group_info == (MSLGroupInfo *) NULL))
7710 ThrowFatalException(ResourceLimitFatalError,
7711 "UnableToInterpretMSLImage");
7712 *msl_info.image_info=CloneImageInfo(image_info);
7713 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7714 *msl_info.attributes=AcquireImage(image_info,exception);
7715 msl_info.group_info[0].numImages=0;
7716 /* the first slot is used to point to the MSL file image */
7717 *msl_info.image=msl_image;
7718 if (*image != (Image *) NULL)
7719 MSLPushImage(&msl_info,*image);
7720 (void) xmlSubstituteEntitiesDefault(1);
7721 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7722 sax_modules.internalSubset=MSLInternalSubset;
7723 sax_modules.isStandalone=MSLIsStandalone;
7724 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7725 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7726 sax_modules.resolveEntity=MSLResolveEntity;
7727 sax_modules.getEntity=MSLGetEntity;
7728 sax_modules.entityDecl=MSLEntityDeclaration;
7729 sax_modules.notationDecl=MSLNotationDeclaration;
7730 sax_modules.attributeDecl=MSLAttributeDeclaration;
7731 sax_modules.elementDecl=MSLElementDeclaration;
7732 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7733 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7734 sax_modules.startDocument=MSLStartDocument;
7735 sax_modules.endDocument=MSLEndDocument;
7736 sax_modules.startElement=MSLStartElement;
7737 sax_modules.endElement=MSLEndElement;
7738 sax_modules.reference=MSLReference;
7739 sax_modules.characters=MSLCharacters;
7740 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7741 sax_modules.processingInstruction=MSLProcessingInstructions;
7742 sax_modules.comment=MSLComment;
7743 sax_modules.warning=MSLWarning;
7744 sax_modules.error=MSLError;
7745 sax_modules.fatalError=MSLError;
7746 sax_modules.getParameterEntity=MSLGetParameterEntity;
7747 sax_modules.cdataBlock=MSLCDataBlock;
7748 sax_modules.externalSubset=MSLExternalSubset;
7749 sax_handler=(&sax_modules);
7750 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7751 msl_image->filename);
7752 while (ReadBlobString(msl_image,message) != (char *) NULL)
7754 n=(ssize_t) strlen(message);
7757 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7760 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7761 if (msl_info.exception->severity >= ErrorException)
7764 if (msl_info.exception->severity == UndefinedException)
7765 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7766 xmlFreeParserCtxt(msl_info.parser);
7767 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7769 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7770 msl_info.group_info);
7771 if (*image == (Image *) NULL)
7772 *image=(*msl_info.image);
7773 if (msl_info.exception->severity != UndefinedException)
7774 return(MagickFalse);
7778 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7786 assert(image_info != (const ImageInfo *) NULL);
7787 assert(image_info->signature == MagickSignature);
7788 if (image_info->debug != MagickFalse)
7789 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7790 image_info->filename);
7791 assert(exception != (ExceptionInfo *) NULL);
7792 assert(exception->signature == MagickSignature);
7793 image=(Image *) NULL;
7794 (void) ProcessMSLScript(image_info,&image,exception);
7795 return(GetFirstImageInList(image));
7800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7804 % R e g i s t e r M S L I m a g e %
7808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7810 % RegisterMSLImage() adds attributes for the MSL image format to
7811 % the list of supported formats. The attributes include the image format
7812 % tag, a method to read and/or write the format, whether the format
7813 % supports the saving of more than one frame to the same file or blob,
7814 % whether the format supports native in-memory I/O, and a brief
7815 % description of the format.
7817 % The format of the RegisterMSLImage method is:
7819 % size_t RegisterMSLImage(void)
7822 ModuleExport size_t RegisterMSLImage(void)
7827 entry=SetMagickInfo("MSL");
7828 #if defined(MAGICKCORE_XML_DELEGATE)
7829 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7830 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7832 entry->description=ConstantString("Magick Scripting Language");
7833 entry->module=ConstantString("MSL");
7834 (void) RegisterMagickInfo(entry);
7835 return(MagickImageCoderSignature);
7838 #if defined(MAGICKCORE_XML_DELEGATE)
7840 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7844 % S e t M S L A t t r i b u t e s %
7848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7850 % SetMSLAttributes() ...
7852 % The format of the SetMSLAttributes method is:
7854 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7855 % const char *keyword,const char *value)
7857 % A description of each parameter follows:
7859 % o msl_info: the MSL info.
7861 % o keyword: the keyword.
7863 % o value: the value.
7866 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7893 assert(msl_info != (MSLInfo *) NULL);
7894 if (keyword == (const char *) NULL)
7896 if (value == (const char *) NULL)
7898 exception=msl_info->exception;
7900 attributes=msl_info->attributes[n];
7901 image_info=msl_info->image_info[n];
7902 draw_info=msl_info->draw_info[n];
7903 image=msl_info->image[n];
7909 if (LocaleCompare(keyword,"adjoin") == 0)
7914 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7916 ThrowMSLException(OptionError,"UnrecognizedType",value);
7917 image_info->adjoin=(MagickBooleanType) adjoin;
7920 if (LocaleCompare(keyword,"alpha") == 0)
7925 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7927 ThrowMSLException(OptionError,"UnrecognizedType",value);
7928 if (image != (Image *) NULL)
7929 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7933 if (LocaleCompare(keyword,"antialias") == 0)
7938 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7940 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7941 image_info->antialias=(MagickBooleanType) antialias;
7944 if (LocaleCompare(keyword,"area-limit") == 0)
7949 limit=MagickResourceInfinity;
7950 if (LocaleCompare(value,"unlimited") != 0)
7951 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
7952 (void) SetMagickResourceLimit(AreaResource,limit);
7955 if (LocaleCompare(keyword,"attenuate") == 0)
7957 (void) SetImageOption(image_info,keyword,value);
7960 if (LocaleCompare(keyword,"authenticate") == 0)
7962 (void) CloneString(&image_info->density,value);
7965 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7971 if (LocaleCompare(keyword,"background") == 0)
7973 (void) QueryColorCompliance(value,AllCompliance,
7974 &image_info->background_color,exception);
7977 if (LocaleCompare(keyword,"blue-primary") == 0)
7979 if (image == (Image *) NULL)
7981 flags=ParseGeometry(value,&geometry_info);
7982 image->chromaticity.blue_primary.x=geometry_info.rho;
7983 image->chromaticity.blue_primary.y=geometry_info.sigma;
7984 if ((flags & SigmaValue) == 0)
7985 image->chromaticity.blue_primary.y=
7986 image->chromaticity.blue_primary.x;
7989 if (LocaleCompare(keyword,"bordercolor") == 0)
7991 (void) QueryColorCompliance(value,AllCompliance,
7992 &image_info->border_color,exception);
7995 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8001 if (LocaleCompare(keyword,"density") == 0)
8003 (void) CloneString(&image_info->density,value);
8004 (void) CloneString(&draw_info->density,value);
8007 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8013 if (LocaleCompare(keyword,"fill") == 0)
8015 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8017 (void) SetImageOption(image_info,keyword,value);
8020 if (LocaleCompare(keyword,"filename") == 0)
8022 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8025 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8031 if (LocaleCompare(keyword,"gravity") == 0)
8036 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8038 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8039 (void) SetImageOption(image_info,keyword,value);
8042 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8048 if (LocaleCompare(keyword,"id") == 0)
8050 (void) SetImageProperty(attributes,keyword,value,exception);
8053 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8059 if (LocaleCompare(keyword,"magick") == 0)
8061 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8064 if (LocaleCompare(keyword,"mattecolor") == 0)
8066 (void) QueryColorCompliance(value,AllCompliance,
8067 &image_info->matte_color,exception);
8070 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8076 if (LocaleCompare(keyword,"pointsize") == 0)
8078 image_info->pointsize=StringToDouble(value,(char **) NULL);
8079 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8082 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8088 if (LocaleCompare(keyword,"quality") == 0)
8090 image_info->quality=StringToLong(value);
8091 if (image == (Image *) NULL)
8093 image->quality=StringToLong(value);
8101 if (LocaleCompare(keyword,"size") == 0)
8103 (void) CloneString(&image_info->size,value);
8106 if (LocaleCompare(keyword,"stroke") == 0)
8108 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8110 (void) SetImageOption(image_info,keyword,value);
8113 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8118 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8131 % U n r e g i s t e r M S L I m a g e %
8135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8137 % UnregisterMSLImage() removes format registrations made by the
8138 % MSL module from the list of supported formats.
8140 % The format of the UnregisterMSLImage method is:
8142 % UnregisterMSLImage(void)
8145 ModuleExport void UnregisterMSLImage(void)
8147 (void) UnregisterMagickInfo("MSL");
8150 #if defined(MAGICKCORE_XML_DELEGATE)
8152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8156 % W r i t e M S L I m a g e %
8160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8162 % WriteMSLImage() writes an image to a file in MVG image format.
8164 % The format of the WriteMSLImage method is:
8166 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8167 % Image *image,ExceptionInfo *exception)
8169 % A description of each parameter follows.
8171 % o image_info: the image info.
8173 % o image: The image.
8175 % o exception: return any errors or warnings in this structure.
8178 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8179 ExceptionInfo *exception)
8181 assert(image_info != (const ImageInfo *) NULL);
8182 assert(image_info->signature == MagickSignature);
8183 assert(image != (Image *) NULL);
8184 assert(image->signature == MagickSignature);
8185 if (image->debug != MagickFalse)
8186 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8187 (void) ReferenceImage(image);
8188 (void) ProcessMSLScript(image_info,&image,exception);