2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2017 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/attribute.h"
48 #include "MagickCore/blob.h"
49 #include "MagickCore/blob-private.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/cache-view.h"
52 #include "MagickCore/channel.h"
53 #include "MagickCore/color.h"
54 #include "MagickCore/color-private.h"
55 #include "MagickCore/colormap.h"
56 #include "MagickCore/composite.h"
57 #include "MagickCore/constitute.h"
58 #include "MagickCore/decorate.h"
59 #include "MagickCore/display.h"
60 #include "MagickCore/distort.h"
61 #include "MagickCore/draw.h"
62 #include "MagickCore/effect.h"
63 #include "MagickCore/enhance.h"
64 #include "MagickCore/exception.h"
65 #include "MagickCore/exception-private.h"
66 #include "MagickCore/fx.h"
67 #include "MagickCore/geometry.h"
68 #include "MagickCore/image.h"
69 #include "MagickCore/image-private.h"
70 #include "MagickCore/list.h"
71 #include "MagickCore/log.h"
72 #include "MagickCore/magick.h"
73 #include "MagickCore/memory_.h"
74 #include "MagickCore/module.h"
75 #include "MagickCore/option.h"
76 #include "MagickCore/paint.h"
77 #include "MagickCore/pixel-accessor.h"
78 #include "MagickCore/profile.h"
79 #include "MagickCore/property.h"
80 #include "MagickCore/quantize.h"
81 #include "MagickCore/quantum-private.h"
82 #include "MagickCore/registry.h"
83 #include "MagickCore/resize.h"
84 #include "MagickCore/resource_.h"
85 #include "MagickCore/segment.h"
86 #include "MagickCore/shear.h"
87 #include "MagickCore/signature.h"
88 #include "MagickCore/statistic.h"
89 #include "MagickCore/static.h"
90 #include "MagickCore/string_.h"
91 #include "MagickCore/string-private.h"
92 #include "MagickCore/transform.h"
93 #include "MagickCore/threshold.h"
94 #include "MagickCore/utility.h"
95 #if defined(MAGICKCORE_XML_DELEGATE)
96 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
97 # if !defined(__MINGW32__) && !defined(__MINGW64__)
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)
205 key[MagickPathExtent];
216 (void) FormatLocaleString(key,MagickPathExtent,"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,MagickPathExtent);
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 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
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 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
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)
616 key[MagickPathExtent],
662 Called when an opening tag has been processed.
664 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
665 " SAX.startElement(%s",tag);
666 exception=AcquireExceptionInfo();
667 msl_info=(MSLInfo *) context;
669 keyword=(const char *) NULL;
671 SetGeometryInfo(&geometry_info);
672 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
673 channel=DefaultChannels;
679 if (LocaleCompare((const char *) tag,"add-noise") == 0)
690 if (msl_info->image[n] == (Image *) NULL)
692 ThrowMSLException(OptionError,"NoImagesDefined",
697 if (attributes != (const xmlChar **) NULL)
698 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
700 keyword=(const char *) attributes[i++];
701 attribute=InterpretImageProperties(msl_info->image_info[n],
702 msl_info->attributes[n],(const char *) attributes[i],
704 CloneString(&value,attribute);
710 if (LocaleCompare(keyword,"channel") == 0)
712 option=ParseChannelOption(value);
714 ThrowMSLException(OptionError,"UnrecognizedChannelType",
716 channel=(ChannelType) option;
719 ThrowMSLException(OptionError,"UnrecognizedAttribute",
726 if (LocaleCompare(keyword,"noise") == 0)
728 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
731 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
733 noise=(NoiseType) option;
736 ThrowMSLException(OptionError,"UnrecognizedAttribute",
742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
748 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
749 noise_image=AddNoiseImage(msl_info->image[n],noise,1.0,
750 msl_info->exception);
751 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
752 if (noise_image == (Image *) NULL)
754 msl_info->image[n]=DestroyImage(msl_info->image[n]);
755 msl_info->image[n]=noise_image;
758 if (LocaleCompare((const char *) tag,"annotate") == 0)
761 text[MagickPathExtent];
766 if (msl_info->image[n] == (Image *) NULL)
768 ThrowMSLException(OptionError,"NoImagesDefined",
772 draw_info=CloneDrawInfo(msl_info->image_info[n],
773 msl_info->draw_info[n]);
775 current=draw_info->affine;
776 GetAffineMatrix(&affine);
777 if (attributes != (const xmlChar **) NULL)
778 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
780 keyword=(const char *) attributes[i++];
781 attribute=InterpretImageProperties(msl_info->image_info[n],
782 msl_info->attributes[n],(const char *) attributes[i],
784 CloneString(&value,attribute);
790 if (LocaleCompare(keyword,"affine") == 0)
796 draw_info->affine.sx=StringToDouble(p,&p);
799 draw_info->affine.rx=StringToDouble(p,&p);
802 draw_info->affine.ry=StringToDouble(p,&p);
805 draw_info->affine.sy=StringToDouble(p,&p);
808 draw_info->affine.tx=StringToDouble(p,&p);
811 draw_info->affine.ty=StringToDouble(p,&p);
814 if (LocaleCompare(keyword,"align") == 0)
816 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
819 ThrowMSLException(OptionError,"UnrecognizedAlignType",
821 draw_info->align=(AlignType) option;
824 if (LocaleCompare(keyword,"antialias") == 0)
826 option=ParseCommandOption(MagickBooleanOptions,
829 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
831 draw_info->stroke_antialias=(MagickBooleanType) option;
832 draw_info->text_antialias=(MagickBooleanType) option;
835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
842 if (LocaleCompare(keyword,"density") == 0)
844 CloneString(&draw_info->density,value);
847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
854 if (LocaleCompare(keyword,"encoding") == 0)
856 CloneString(&draw_info->encoding,value);
859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
866 if (LocaleCompare(keyword, "fill") == 0)
868 (void) QueryColorCompliance(value,AllCompliance,
869 &draw_info->fill,exception);
872 if (LocaleCompare(keyword,"family") == 0)
874 CloneString(&draw_info->family,value);
877 if (LocaleCompare(keyword,"font") == 0)
879 CloneString(&draw_info->font,value);
882 ThrowMSLException(OptionError,"UnrecognizedAttribute",
889 if (LocaleCompare(keyword,"geometry") == 0)
891 flags=ParseGravityGeometry(msl_info->image[n],value,
892 &geometry,exception);
895 if (LocaleCompare(keyword,"gravity") == 0)
897 option=ParseCommandOption(MagickGravityOptions,
900 ThrowMSLException(OptionError,"UnrecognizedGravityType",
902 draw_info->gravity=(GravityType) option;
905 ThrowMSLException(OptionError,"UnrecognizedAttribute",
912 if (LocaleCompare(keyword,"pointsize") == 0)
914 draw_info->pointsize=StringToDouble(value,(char **) NULL);
917 ThrowMSLException(OptionError,"UnrecognizedAttribute",
924 if (LocaleCompare(keyword,"rotate") == 0)
926 angle=StringToDouble(value,(char **) NULL);
927 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
928 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
929 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
930 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
933 ThrowMSLException(OptionError,"UnrecognizedAttribute",
940 if (LocaleCompare(keyword,"scale") == 0)
942 flags=ParseGeometry(value,&geometry_info);
943 if ((flags & SigmaValue) == 0)
944 geometry_info.sigma=1.0;
945 affine.sx=geometry_info.rho;
946 affine.sy=geometry_info.sigma;
949 if (LocaleCompare(keyword,"skewX") == 0)
951 angle=StringToDouble(value,(char **) NULL);
952 affine.ry=tan(DegreesToRadians(fmod((double) angle,
956 if (LocaleCompare(keyword,"skewY") == 0)
958 angle=StringToDouble(value,(char **) NULL);
959 affine.rx=tan(DegreesToRadians(fmod((double) angle,
963 if (LocaleCompare(keyword,"stretch") == 0)
965 option=ParseCommandOption(MagickStretchOptions,
968 ThrowMSLException(OptionError,"UnrecognizedStretchType",
970 draw_info->stretch=(StretchType) option;
973 if (LocaleCompare(keyword, "stroke") == 0)
975 (void) QueryColorCompliance(value,AllCompliance,
976 &draw_info->stroke,exception);
979 if (LocaleCompare(keyword,"strokewidth") == 0)
981 draw_info->stroke_width=StringToLong(value);
984 if (LocaleCompare(keyword,"style") == 0)
986 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
989 ThrowMSLException(OptionError,"UnrecognizedStyleType",
991 draw_info->style=(StyleType) option;
994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1001 if (LocaleCompare(keyword,"text") == 0)
1003 CloneString(&draw_info->text,value);
1006 if (LocaleCompare(keyword,"translate") == 0)
1008 flags=ParseGeometry(value,&geometry_info);
1009 if ((flags & SigmaValue) == 0)
1010 geometry_info.sigma=1.0;
1011 affine.tx=geometry_info.rho;
1012 affine.ty=geometry_info.sigma;
1015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1022 if (LocaleCompare(keyword, "undercolor") == 0)
1024 (void) QueryColorCompliance(value,AllCompliance,
1025 &draw_info->undercolor,exception);
1028 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1035 if (LocaleCompare(keyword,"weight") == 0)
1037 draw_info->weight=StringToLong(value);
1040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1047 if (LocaleCompare(keyword,"x") == 0)
1049 geometry.x=StringToLong(value);
1052 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1059 if (LocaleCompare(keyword,"y") == 0)
1061 geometry.y=StringToLong(value);
1064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1070 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1076 (void) FormatLocaleString(text,MagickPathExtent,
1077 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1078 geometry.height,(double) geometry.x,(double) geometry.y);
1079 CloneString(&draw_info->geometry,text);
1080 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1081 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1082 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1083 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1084 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1086 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1088 (void) AnnotateImage(msl_info->image[n],draw_info,
1089 msl_info->exception);
1090 draw_info=DestroyDrawInfo(draw_info);
1093 if (LocaleCompare((const char *) tag,"append") == 0)
1101 if (msl_info->image[n] == (Image *) NULL)
1103 ThrowMSLException(OptionError,"NoImagesDefined",
1104 (const char *) tag);
1108 if (attributes != (const xmlChar **) NULL)
1109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1111 keyword=(const char *) attributes[i++];
1112 attribute=InterpretImageProperties(msl_info->image_info[n],
1113 msl_info->attributes[n],(const char *) attributes[i],
1115 CloneString(&value,attribute);
1121 if (LocaleCompare(keyword,"stack") == 0)
1123 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1126 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1128 stack=(MagickBooleanType) option;
1131 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1137 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1143 append_image=AppendImages(msl_info->image[n],stack,
1144 msl_info->exception);
1145 if (append_image == (Image *) NULL)
1147 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1148 msl_info->image[n]=append_image;
1151 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1157 if (LocaleCompare((const char *) tag,"blur") == 0)
1165 if (msl_info->image[n] == (Image *) NULL)
1167 ThrowMSLException(OptionError,"NoImagesDefined",
1168 (const char *) tag);
1171 if (attributes != (const xmlChar **) NULL)
1172 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1174 keyword=(const char *) attributes[i++];
1175 attribute=InterpretImageProperties(msl_info->image_info[n],
1176 msl_info->attributes[n],(const char *) attributes[i],
1178 CloneString(&value,attribute);
1184 if (LocaleCompare(keyword,"channel") == 0)
1186 option=ParseChannelOption(value);
1188 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1190 channel=(ChannelType) option;
1193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1200 if (LocaleCompare(keyword,"geometry") == 0)
1202 flags=ParseGeometry(value,&geometry_info);
1203 if ((flags & SigmaValue) == 0)
1204 geometry_info.sigma=1.0;
1207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1214 if (LocaleCompare(keyword,"radius") == 0)
1216 geometry_info.rho=StringToDouble(value,(char **) NULL);
1219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1226 if (LocaleCompare(keyword,"sigma") == 0)
1228 geometry_info.sigma=StringToLong(value);
1231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1243 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
1244 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1245 geometry_info.sigma,msl_info->exception);
1246 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
1247 if (blur_image == (Image *) NULL)
1249 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1250 msl_info->image[n]=blur_image;
1253 if (LocaleCompare((const char *) tag,"border") == 0)
1261 if (msl_info->image[n] == (Image *) NULL)
1263 ThrowMSLException(OptionError,"NoImagesDefined",
1264 (const char *) tag);
1267 SetGeometry(msl_info->image[n],&geometry);
1268 if (attributes != (const xmlChar **) NULL)
1269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1271 keyword=(const char *) attributes[i++];
1272 attribute=InterpretImageProperties(msl_info->image_info[n],
1273 msl_info->attributes[n],(const char *) attributes[i],
1275 CloneString(&value,attribute);
1281 if (LocaleCompare(keyword,"compose") == 0)
1283 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1286 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1288 msl_info->image[n]->compose=(CompositeOperator) option;
1291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1298 if (LocaleCompare(keyword, "fill") == 0)
1300 (void) QueryColorCompliance(value,AllCompliance,
1301 &msl_info->image[n]->border_color,exception);
1304 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1311 if (LocaleCompare(keyword,"geometry") == 0)
1313 flags=ParsePageGeometry(msl_info->image[n],value,
1314 &geometry,exception);
1315 if ((flags & HeightValue) == 0)
1316 geometry.height=geometry.width;
1319 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1326 if (LocaleCompare(keyword,"height") == 0)
1328 geometry.height=StringToLong(value);
1331 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1338 if (LocaleCompare(keyword,"width") == 0)
1340 geometry.width=StringToLong(value);
1343 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1349 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1355 border_image=BorderImage(msl_info->image[n],&geometry,
1356 msl_info->image[n]->compose,msl_info->exception);
1357 if (border_image == (Image *) NULL)
1359 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1360 msl_info->image[n]=border_image;
1363 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1368 if (LocaleCompare((const char *) tag,"colorize") == 0)
1371 blend[MagickPathExtent];
1382 if (msl_info->image[n] == (Image *) NULL)
1384 ThrowMSLException(OptionError,"NoImagesDefined",
1385 (const char *) tag);
1388 GetPixelInfo(msl_info->image[n],&target);
1389 (void) CopyMagickString(blend,"100",MagickPathExtent);
1390 if (attributes != (const xmlChar **) NULL)
1391 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1393 keyword=(const char *) attributes[i++];
1394 attribute=InterpretImageProperties(msl_info->image_info[n],
1395 msl_info->attributes[n],(const char *) attributes[i],
1397 CloneString(&value,attribute);
1403 if (LocaleCompare(keyword,"blend") == 0)
1405 (void) CopyMagickString(blend,value,MagickPathExtent);
1408 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1415 if (LocaleCompare(keyword,"fill") == 0)
1417 (void) QueryColorCompliance(value,AllCompliance,
1418 &target,msl_info->exception);
1421 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1427 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1433 colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
1434 msl_info->exception);
1435 if (colorize_image == (Image *) NULL)
1437 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1438 msl_info->image[n]=colorize_image;
1441 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1447 if (msl_info->image[n] == (Image *) NULL)
1449 ThrowMSLException(OptionError,"NoImagesDefined",
1450 (const char *) tag);
1454 NOTE: charcoal can have no attributes, since we use all the defaults!
1456 if (attributes != (const xmlChar **) NULL)
1458 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1460 keyword=(const char *) attributes[i++];
1461 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1462 msl_info->attributes[n],(const char *) attributes[i],exception));
1468 if (LocaleCompare(keyword,"radius") == 0)
1470 radius=StringToDouble(value,(char **) NULL);
1473 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1479 if (LocaleCompare(keyword,"sigma") == 0)
1481 sigma = StringToLong( value );
1484 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1503 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1504 msl_info->exception);
1505 if (newImage == (Image *) NULL)
1507 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1508 msl_info->image[n]=newImage;
1512 if (LocaleCompare((const char *) tag,"chop") == 0)
1520 if (msl_info->image[n] == (Image *) NULL)
1522 ThrowMSLException(OptionError,"NoImagesDefined",
1523 (const char *) tag);
1526 SetGeometry(msl_info->image[n],&geometry);
1527 if (attributes != (const xmlChar **) NULL)
1528 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1530 keyword=(const char *) attributes[i++];
1531 attribute=InterpretImageProperties(msl_info->image_info[n],
1532 msl_info->attributes[n],(const char *) attributes[i],
1534 CloneString(&value,attribute);
1540 if (LocaleCompare(keyword,"geometry") == 0)
1542 flags=ParsePageGeometry(msl_info->image[n],value,
1543 &geometry,exception);
1544 if ((flags & HeightValue) == 0)
1545 geometry.height=geometry.width;
1548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1555 if (LocaleCompare(keyword,"height") == 0)
1557 geometry.height=StringToLong(value);
1560 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1567 if (LocaleCompare(keyword,"width") == 0)
1569 geometry.width=StringToLong(value);
1572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1579 if (LocaleCompare(keyword,"x") == 0)
1581 geometry.x=StringToLong(value);
1584 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1591 if (LocaleCompare(keyword,"y") == 0)
1593 geometry.y=StringToLong(value);
1596 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1602 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1608 chop_image=ChopImage(msl_info->image[n],&geometry,
1609 msl_info->exception);
1610 if (chop_image == (Image *) NULL)
1612 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1613 msl_info->image[n]=chop_image;
1616 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1625 Color floodfill image.
1627 if (msl_info->image[n] == (Image *) NULL)
1629 ThrowMSLException(OptionError,"NoImagesDefined",
1630 (const char *) tag);
1633 draw_info=CloneDrawInfo(msl_info->image_info[n],
1634 msl_info->draw_info[n]);
1635 SetGeometry(msl_info->image[n],&geometry);
1636 paint_method=FloodfillMethod;
1637 if (attributes != (const xmlChar **) NULL)
1638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1640 keyword=(const char *) attributes[i++];
1641 attribute=InterpretImageProperties(msl_info->image_info[n],
1642 msl_info->attributes[n],(const char *) attributes[i],
1644 CloneString(&value,attribute);
1650 if (LocaleCompare(keyword,"bordercolor") == 0)
1652 (void) QueryColorCompliance(value,AllCompliance,
1654 paint_method=FillToBorderMethod;
1657 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1664 if (LocaleCompare(keyword,"fill") == 0)
1666 (void) QueryColorCompliance(value,AllCompliance,
1667 &draw_info->fill,exception);
1670 if (LocaleCompare(keyword,"fuzz") == 0)
1672 msl_info->image[n]->fuzz=StringToDouble(value,
1676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1683 if (LocaleCompare(keyword,"geometry") == 0)
1685 flags=ParsePageGeometry(msl_info->image[n],value,
1686 &geometry,exception);
1687 if ((flags & HeightValue) == 0)
1688 geometry.height=geometry.width;
1689 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1690 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1694 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1701 if (LocaleCompare(keyword,"x") == 0)
1703 geometry.x=StringToLong(value);
1704 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1705 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1716 if (LocaleCompare(keyword,"y") == 0)
1718 geometry.y=StringToLong(value);
1719 (void) GetOneVirtualPixelInfo(msl_info->image[n],
1720 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
1724 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1730 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1736 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1737 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1738 MagickFalse : MagickTrue,msl_info->exception);
1739 draw_info=DestroyDrawInfo(draw_info);
1742 if (LocaleCompare((const char *) tag,"comment") == 0)
1744 if (LocaleCompare((const char *) tag,"composite") == 0)
1747 composite_geometry[MagickPathExtent];
1759 if (msl_info->image[n] == (Image *) NULL)
1761 ThrowMSLException(OptionError,"NoImagesDefined",
1762 (const char *) tag);
1765 composite_image=NewImageList();
1766 compose=OverCompositeOp;
1767 if (attributes != (const xmlChar **) NULL)
1768 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1770 keyword=(const char *) attributes[i++];
1771 attribute=InterpretImageProperties(msl_info->image_info[n],
1772 msl_info->attributes[n],(const char *) attributes[i],
1774 CloneString(&value,attribute);
1780 if (LocaleCompare(keyword,"compose") == 0)
1782 option=ParseCommandOption(MagickComposeOptions,
1785 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1787 compose=(CompositeOperator) option;
1795 if (LocaleCompare(keyword,"image") == 0)
1796 for (j=0; j < msl_info->n; j++)
1801 attribute=GetImageProperty(msl_info->attributes[j],"id",
1803 if ((attribute != (const char *) NULL) &&
1804 (LocaleCompare(attribute,value) == 0))
1806 composite_image=CloneImage(msl_info->image[j],0,0,
1807 MagickFalse,exception);
1817 if (composite_image == (Image *) NULL)
1819 rotate_image=NewImageList();
1820 SetGeometry(msl_info->image[n],&geometry);
1821 if (attributes != (const xmlChar **) NULL)
1822 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1824 keyword=(const char *) attributes[i++];
1825 attribute=InterpretImageProperties(msl_info->image_info[n],
1826 msl_info->attributes[n],(const char *) attributes[i],
1828 CloneString(&value,attribute);
1834 if (LocaleCompare(keyword,"blend") == 0)
1836 (void) SetImageArtifact(composite_image,
1837 "compose:args",value);
1840 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1847 if (LocaleCompare(keyword,"channel") == 0)
1849 option=ParseChannelOption(value);
1851 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1853 channel=(ChannelType) option;
1856 if (LocaleCompare(keyword, "color") == 0)
1858 (void) QueryColorCompliance(value,AllCompliance,
1859 &composite_image->background_color,exception);
1862 if (LocaleCompare(keyword,"compose") == 0)
1864 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1871 if (LocaleCompare(keyword,"geometry") == 0)
1873 flags=ParsePageGeometry(msl_info->image[n],value,
1874 &geometry,exception);
1875 if ((flags & HeightValue) == 0)
1876 geometry.height=geometry.width;
1879 if (LocaleCompare(keyword,"gravity") == 0)
1881 option=ParseCommandOption(MagickGravityOptions,
1884 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1886 msl_info->image[n]->gravity=(GravityType) option;
1889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1896 if (LocaleCompare(keyword,"image") == 0)
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"mask") == 0)
1906 for (j=0; j < msl_info->n; j++)
1911 attribute=GetImageProperty(msl_info->attributes[j],"id",
1913 if ((attribute != (const char *) NULL) &&
1914 (LocaleCompare(value,value) == 0))
1916 SetImageType(composite_image,TrueColorAlphaType,
1918 (void) CompositeImage(composite_image,
1919 msl_info->image[j],CopyAlphaCompositeOp,MagickTrue,
1924 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1931 if (LocaleCompare(keyword,"opacity") == 0)
1946 opacity=StringToLong(value);
1947 if (compose != DissolveCompositeOp)
1949 (void) SetImageAlpha(composite_image,(Quantum)
1953 (void) SetImageArtifact(msl_info->image[n],
1954 "compose:args",value);
1955 if (composite_image->alpha_trait == UndefinedPixelTrait)
1956 (void) SetImageAlpha(composite_image,OpaqueAlpha,
1958 composite_view=AcquireAuthenticCacheView(composite_image,exception);
1959 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1961 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1962 (ssize_t) composite_image->columns,1,exception);
1963 for (x=0; x < (ssize_t) composite_image->columns; x++)
1965 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1966 SetPixelAlpha(composite_image,
1967 ClampToQuantum(opacity),q);
1968 q+=GetPixelChannels(composite_image);
1970 if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
1973 composite_view=DestroyCacheView(composite_view);
1976 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1983 if (LocaleCompare(keyword,"rotate") == 0)
1985 rotate_image=RotateImage(composite_image,
1986 StringToDouble(value,(char **) NULL),exception);
1989 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1996 if (LocaleCompare(keyword,"tile") == 0)
2001 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2004 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2006 tile=(MagickBooleanType) option;
2008 if (rotate_image != (Image *) NULL)
2009 (void) SetImageArtifact(rotate_image,
2010 "compose:outside-overlay","false");
2012 (void) SetImageArtifact(composite_image,
2013 "compose:outside-overlay","false");
2014 image=msl_info->image[n];
2015 height=composite_image->rows;
2016 width=composite_image->columns;
2017 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2018 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2020 if (rotate_image != (Image *) NULL)
2021 (void) CompositeImage(image,rotate_image,compose,
2022 MagickTrue,x,y,exception);
2024 (void) CompositeImage(image,composite_image,
2025 compose,MagickTrue,x,y,exception);
2027 if (rotate_image != (Image *) NULL)
2028 rotate_image=DestroyImage(rotate_image);
2031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2038 if (LocaleCompare(keyword,"x") == 0)
2040 geometry.x=StringToLong(value);
2043 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2050 if (LocaleCompare(keyword,"y") == 0)
2052 geometry.y=StringToLong(value);
2055 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2061 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2067 image=msl_info->image[n];
2068 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
2069 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2070 (double) composite_image->rows,(double) geometry.x,(double)
2072 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2074 channel_mask=SetImageChannelMask(image,channel);
2075 if (rotate_image == (Image *) NULL)
2076 CompositeImage(image,composite_image,compose,MagickTrue,geometry.x,
2077 geometry.y,exception);
2083 geometry.x-=(ssize_t) (rotate_image->columns-
2084 composite_image->columns)/2;
2085 geometry.y-=(ssize_t) (rotate_image->rows-
2086 composite_image->rows)/2;
2087 CompositeImage(image,rotate_image,compose,MagickTrue,geometry.x,
2088 geometry.y,exception);
2089 rotate_image=DestroyImage(rotate_image);
2091 (void) SetImageChannelMask(image,channel_mask);
2092 composite_image=DestroyImage(composite_image);
2095 if (LocaleCompare((const char *) tag,"contrast") == 0)
2103 if (msl_info->image[n] == (Image *) NULL)
2105 ThrowMSLException(OptionError,"NoImagesDefined",
2106 (const char *) tag);
2109 sharpen=MagickFalse;
2110 if (attributes != (const xmlChar **) NULL)
2111 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2113 keyword=(const char *) attributes[i++];
2114 attribute=InterpretImageProperties(msl_info->image_info[n],
2115 msl_info->attributes[n],(const char *) attributes[i],
2117 CloneString(&value,attribute);
2123 if (LocaleCompare(keyword,"sharpen") == 0)
2125 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2128 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2130 sharpen=(MagickBooleanType) option;
2133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2139 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2145 (void) ContrastImage(msl_info->image[n],sharpen,
2146 msl_info->exception);
2149 if (LocaleCompare((const char *) tag,"crop") == 0)
2157 if (msl_info->image[n] == (Image *) NULL)
2159 ThrowMSLException(OptionError,"NoImagesDefined",
2160 (const char *) tag);
2163 SetGeometry(msl_info->image[n],&geometry);
2164 if (attributes != (const xmlChar **) NULL)
2165 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2167 keyword=(const char *) attributes[i++];
2168 attribute=InterpretImageProperties(msl_info->image_info[n],
2169 msl_info->attributes[n],(const char *) attributes[i],
2171 CloneString(&value,attribute);
2177 if (LocaleCompare(keyword,"geometry") == 0)
2179 flags=ParseGravityGeometry(msl_info->image[n],value,
2180 &geometry,exception);
2183 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2190 if (LocaleCompare(keyword,"height") == 0)
2192 geometry.height=StringToLong(value);
2195 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2202 if (LocaleCompare(keyword,"width") == 0)
2204 geometry.width=StringToLong(value);
2207 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2214 if (LocaleCompare(keyword,"x") == 0)
2216 geometry.x=StringToLong(value);
2219 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2226 if (LocaleCompare(keyword,"y") == 0)
2228 geometry.y=StringToLong(value);
2231 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2243 crop_image=CropImage(msl_info->image[n],&geometry,
2244 msl_info->exception);
2245 if (crop_image == (Image *) NULL)
2247 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2248 msl_info->image[n]=crop_image;
2251 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2257 Cycle-colormap image.
2259 if (msl_info->image[n] == (Image *) NULL)
2261 ThrowMSLException(OptionError,"NoImagesDefined",
2262 (const char *) tag);
2266 if (attributes != (const xmlChar **) NULL)
2267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2269 keyword=(const char *) attributes[i++];
2270 attribute=InterpretImageProperties(msl_info->image_info[n],
2271 msl_info->attributes[n],(const char *) attributes[i],
2273 CloneString(&value,attribute);
2279 if (LocaleCompare(keyword,"display") == 0)
2281 display=StringToLong(value);
2284 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2290 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2296 (void) CycleColormapImage(msl_info->image[n],display,exception);
2299 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2304 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2312 if (msl_info->image[n] == (Image *) NULL)
2314 ThrowMSLException(OptionError,"NoImagesDefined",
2315 (const char *) tag);
2318 if (attributes != (const xmlChar **) NULL)
2319 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2321 keyword=(const char *) attributes[i++];
2322 attribute=InterpretImageProperties(msl_info->image_info[n],
2323 msl_info->attributes[n],(const char *) attributes[i],
2325 CloneString(&value,attribute);
2326 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2328 despeckle_image=DespeckleImage(msl_info->image[n],
2329 msl_info->exception);
2330 if (despeckle_image == (Image *) NULL)
2332 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2333 msl_info->image[n]=despeckle_image;
2336 if (LocaleCompare((const char *) tag,"display") == 0)
2338 if (msl_info->image[n] == (Image *) NULL)
2340 ThrowMSLException(OptionError,"NoImagesDefined",
2341 (const char *) tag);
2344 if (attributes != (const xmlChar **) NULL)
2345 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2347 keyword=(const char *) attributes[i++];
2348 attribute=InterpretImageProperties(msl_info->image_info[n],
2349 msl_info->attributes[n],(const char *) attributes[i],
2351 CloneString(&value,attribute);
2356 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2362 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2363 msl_info->exception);
2366 if (LocaleCompare((const char *) tag,"draw") == 0)
2369 text[MagickPathExtent];
2374 if (msl_info->image[n] == (Image *) NULL)
2376 ThrowMSLException(OptionError,"NoImagesDefined",
2377 (const char *) tag);
2380 draw_info=CloneDrawInfo(msl_info->image_info[n],
2381 msl_info->draw_info[n]);
2383 current=draw_info->affine;
2384 GetAffineMatrix(&affine);
2385 if (attributes != (const xmlChar **) NULL)
2386 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2388 keyword=(const char *) attributes[i++];
2389 attribute=InterpretImageProperties(msl_info->image_info[n],
2390 msl_info->attributes[n],(const char *) attributes[i],
2392 CloneString(&value,attribute);
2398 if (LocaleCompare(keyword,"affine") == 0)
2404 draw_info->affine.sx=StringToDouble(p,&p);
2407 draw_info->affine.rx=StringToDouble(p,&p);
2410 draw_info->affine.ry=StringToDouble(p,&p);
2413 draw_info->affine.sy=StringToDouble(p,&p);
2416 draw_info->affine.tx=StringToDouble(p,&p);
2419 draw_info->affine.ty=StringToDouble(p,&p);
2422 if (LocaleCompare(keyword,"align") == 0)
2424 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2427 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2429 draw_info->align=(AlignType) option;
2432 if (LocaleCompare(keyword,"antialias") == 0)
2434 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2437 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2439 draw_info->stroke_antialias=(MagickBooleanType) option;
2440 draw_info->text_antialias=(MagickBooleanType) option;
2443 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2450 if (LocaleCompare(keyword,"density") == 0)
2452 CloneString(&draw_info->density,value);
2455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2462 if (LocaleCompare(keyword,"encoding") == 0)
2464 CloneString(&draw_info->encoding,value);
2467 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2474 if (LocaleCompare(keyword, "fill") == 0)
2476 (void) QueryColorCompliance(value,AllCompliance,
2477 &draw_info->fill,exception);
2480 if (LocaleCompare(keyword,"family") == 0)
2482 CloneString(&draw_info->family,value);
2485 if (LocaleCompare(keyword,"font") == 0)
2487 CloneString(&draw_info->font,value);
2490 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2497 if (LocaleCompare(keyword,"geometry") == 0)
2499 flags=ParsePageGeometry(msl_info->image[n],value,
2500 &geometry,exception);
2501 if ((flags & HeightValue) == 0)
2502 geometry.height=geometry.width;
2505 if (LocaleCompare(keyword,"gravity") == 0)
2507 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2510 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2512 draw_info->gravity=(GravityType) option;
2515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2522 if (LocaleCompare(keyword,"points") == 0)
2524 if (LocaleCompare(draw_info->primitive,"path") == 0)
2526 (void) ConcatenateString(&draw_info->primitive," '");
2527 ConcatenateString(&draw_info->primitive,value);
2528 (void) ConcatenateString(&draw_info->primitive,"'");
2532 (void) ConcatenateString(&draw_info->primitive," ");
2533 ConcatenateString(&draw_info->primitive,value);
2537 if (LocaleCompare(keyword,"pointsize") == 0)
2539 draw_info->pointsize=StringToDouble(value,
2543 if (LocaleCompare(keyword,"primitive") == 0)
2545 CloneString(&draw_info->primitive,value);
2548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2555 if (LocaleCompare(keyword,"rotate") == 0)
2557 angle=StringToDouble(value,(char **) NULL);
2558 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2559 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2560 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2561 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2564 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2571 if (LocaleCompare(keyword,"scale") == 0)
2573 flags=ParseGeometry(value,&geometry_info);
2574 if ((flags & SigmaValue) == 0)
2575 geometry_info.sigma=1.0;
2576 affine.sx=geometry_info.rho;
2577 affine.sy=geometry_info.sigma;
2580 if (LocaleCompare(keyword,"skewX") == 0)
2582 angle=StringToDouble(value,(char **) NULL);
2583 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2586 if (LocaleCompare(keyword,"skewY") == 0)
2588 angle=StringToDouble(value,(char **) NULL);
2589 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2592 if (LocaleCompare(keyword,"stretch") == 0)
2594 option=ParseCommandOption(MagickStretchOptions,
2597 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2599 draw_info->stretch=(StretchType) option;
2602 if (LocaleCompare(keyword, "stroke") == 0)
2604 (void) QueryColorCompliance(value,AllCompliance,
2605 &draw_info->stroke,exception);
2608 if (LocaleCompare(keyword,"strokewidth") == 0)
2610 draw_info->stroke_width=StringToLong(value);
2613 if (LocaleCompare(keyword,"style") == 0)
2615 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2618 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2620 draw_info->style=(StyleType) option;
2623 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2630 if (LocaleCompare(keyword,"text") == 0)
2632 (void) ConcatenateString(&draw_info->primitive," '");
2633 (void) ConcatenateString(&draw_info->primitive,value);
2634 (void) ConcatenateString(&draw_info->primitive,"'");
2637 if (LocaleCompare(keyword,"translate") == 0)
2639 flags=ParseGeometry(value,&geometry_info);
2640 if ((flags & SigmaValue) == 0)
2641 geometry_info.sigma=1.0;
2642 affine.tx=geometry_info.rho;
2643 affine.ty=geometry_info.sigma;
2646 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2653 if (LocaleCompare(keyword, "undercolor") == 0)
2655 (void) QueryColorCompliance(value,AllCompliance,
2656 &draw_info->undercolor,exception);
2659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2666 if (LocaleCompare(keyword,"weight") == 0)
2668 draw_info->weight=StringToLong(value);
2671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2678 if (LocaleCompare(keyword,"x") == 0)
2680 geometry.x=StringToLong(value);
2683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2690 if (LocaleCompare(keyword,"y") == 0)
2692 geometry.y=StringToLong(value);
2695 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2701 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2707 (void) FormatLocaleString(text,MagickPathExtent,
2708 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2709 geometry.height,(double) geometry.x,(double) geometry.y);
2710 CloneString(&draw_info->geometry,text);
2711 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2712 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2713 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2714 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2715 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2717 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2719 (void) DrawImage(msl_info->image[n],draw_info,exception);
2720 draw_info=DestroyDrawInfo(draw_info);
2723 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2728 if (LocaleCompare((const char *) tag,"edge") == 0)
2736 if (msl_info->image[n] == (Image *) NULL)
2738 ThrowMSLException(OptionError,"NoImagesDefined",
2739 (const char *) tag);
2742 if (attributes != (const xmlChar **) NULL)
2743 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2745 keyword=(const char *) attributes[i++];
2746 attribute=InterpretImageProperties(msl_info->image_info[n],
2747 msl_info->attributes[n],(const char *) attributes[i],
2749 CloneString(&value,attribute);
2755 if (LocaleCompare(keyword,"geometry") == 0)
2757 flags=ParseGeometry(value,&geometry_info);
2758 if ((flags & SigmaValue) == 0)
2759 geometry_info.sigma=1.0;
2762 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2769 if (LocaleCompare(keyword,"radius") == 0)
2771 geometry_info.rho=StringToDouble(value,(char **) NULL);
2774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2780 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2786 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2787 msl_info->exception);
2788 if (edge_image == (Image *) NULL)
2790 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2791 msl_info->image[n]=edge_image;
2794 if (LocaleCompare((const char *) tag,"emboss") == 0)
2802 if (msl_info->image[n] == (Image *) NULL)
2804 ThrowMSLException(OptionError,"NoImagesDefined",
2805 (const char *) tag);
2808 if (attributes != (const xmlChar **) NULL)
2809 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2811 keyword=(const char *) attributes[i++];
2812 attribute=InterpretImageProperties(msl_info->image_info[n],
2813 msl_info->attributes[n],(const char *) attributes[i],
2815 CloneString(&value,attribute);
2821 if (LocaleCompare(keyword,"geometry") == 0)
2823 flags=ParseGeometry(value,&geometry_info);
2824 if ((flags & SigmaValue) == 0)
2825 geometry_info.sigma=1.0;
2828 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2835 if (LocaleCompare(keyword,"radius") == 0)
2837 geometry_info.rho=StringToDouble(value,
2841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2848 if (LocaleCompare(keyword,"sigma") == 0)
2850 geometry_info.sigma=StringToLong(value);
2853 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2865 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2866 geometry_info.sigma,msl_info->exception);
2867 if (emboss_image == (Image *) NULL)
2869 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2870 msl_info->image[n]=emboss_image;
2873 if (LocaleCompare((const char *) tag,"enhance") == 0)
2881 if (msl_info->image[n] == (Image *) NULL)
2883 ThrowMSLException(OptionError,"NoImagesDefined",
2884 (const char *) tag);
2887 if (attributes != (const xmlChar **) NULL)
2888 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2890 keyword=(const char *) attributes[i++];
2891 attribute=InterpretImageProperties(msl_info->image_info[n],
2892 msl_info->attributes[n],(const char *) attributes[i],
2894 CloneString(&value,attribute);
2895 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2897 enhance_image=EnhanceImage(msl_info->image[n],
2898 msl_info->exception);
2899 if (enhance_image == (Image *) NULL)
2901 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2902 msl_info->image[n]=enhance_image;
2905 if (LocaleCompare((const char *) tag,"equalize") == 0)
2910 if (msl_info->image[n] == (Image *) NULL)
2912 ThrowMSLException(OptionError,"NoImagesDefined",
2913 (const char *) tag);
2916 if (attributes != (const xmlChar **) NULL)
2917 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2919 keyword=(const char *) attributes[i++];
2920 attribute=InterpretImageProperties(msl_info->image_info[n],
2921 msl_info->attributes[n],(const char *) attributes[i],
2923 CloneString(&value,attribute);
2928 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2934 (void) EqualizeImage(msl_info->image[n],
2935 msl_info->exception);
2938 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2943 if (LocaleCompare((const char *) tag, "flatten") == 0)
2945 if (msl_info->image[n] == (Image *) NULL)
2947 ThrowMSLException(OptionError,"NoImagesDefined",
2948 (const char *) tag);
2952 /* no attributes here */
2954 /* process the image */
2959 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2960 msl_info->exception);
2961 if (newImage == (Image *) NULL)
2963 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2964 msl_info->image[n]=newImage;
2968 if (LocaleCompare((const char *) tag,"flip") == 0)
2976 if (msl_info->image[n] == (Image *) NULL)
2978 ThrowMSLException(OptionError,"NoImagesDefined",
2979 (const char *) tag);
2982 if (attributes != (const xmlChar **) NULL)
2983 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2985 keyword=(const char *) attributes[i++];
2986 attribute=InterpretImageProperties(msl_info->image_info[n],
2987 msl_info->attributes[n],(const char *) attributes[i],
2989 CloneString(&value,attribute);
2990 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2992 flip_image=FlipImage(msl_info->image[n],
2993 msl_info->exception);
2994 if (flip_image == (Image *) NULL)
2996 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2997 msl_info->image[n]=flip_image;
3000 if (LocaleCompare((const char *) tag,"flop") == 0)
3008 if (msl_info->image[n] == (Image *) NULL)
3010 ThrowMSLException(OptionError,"NoImagesDefined",
3011 (const char *) tag);
3014 if (attributes != (const xmlChar **) NULL)
3015 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3017 keyword=(const char *) attributes[i++];
3018 attribute=InterpretImageProperties(msl_info->image_info[n],
3019 msl_info->attributes[n],(const char *) attributes[i],
3021 CloneString(&value,attribute);
3022 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3024 flop_image=FlopImage(msl_info->image[n],
3025 msl_info->exception);
3026 if (flop_image == (Image *) NULL)
3028 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3029 msl_info->image[n]=flop_image;
3032 if (LocaleCompare((const char *) tag,"frame") == 0)
3043 if (msl_info->image[n] == (Image *) NULL)
3045 ThrowMSLException(OptionError,"NoImagesDefined",
3046 (const char *) tag);
3049 (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info));
3050 SetGeometry(msl_info->image[n],&geometry);
3051 if (attributes != (const xmlChar **) NULL)
3052 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3054 keyword=(const char *) attributes[i++];
3055 attribute=InterpretImageProperties(msl_info->image_info[n],
3056 msl_info->attributes[n],(const char *) attributes[i],
3058 CloneString(&value,attribute);
3064 if (LocaleCompare(keyword,"compose") == 0)
3066 option=ParseCommandOption(MagickComposeOptions,
3069 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3071 msl_info->image[n]->compose=(CompositeOperator) option;
3074 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3081 if (LocaleCompare(keyword, "fill") == 0)
3083 (void) QueryColorCompliance(value,AllCompliance,
3084 &msl_info->image[n]->alpha_color,exception);
3087 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3094 if (LocaleCompare(keyword,"geometry") == 0)
3096 flags=ParsePageGeometry(msl_info->image[n],value,
3097 &geometry,exception);
3098 if ((flags & HeightValue) == 0)
3099 geometry.height=geometry.width;
3100 frame_info.width=geometry.width;
3101 frame_info.height=geometry.height;
3102 frame_info.outer_bevel=geometry.x;
3103 frame_info.inner_bevel=geometry.y;
3106 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3113 if (LocaleCompare(keyword,"height") == 0)
3115 frame_info.height=StringToLong(value);
3118 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3125 if (LocaleCompare(keyword,"inner") == 0)
3127 frame_info.inner_bevel=StringToLong(value);
3130 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3137 if (LocaleCompare(keyword,"outer") == 0)
3139 frame_info.outer_bevel=StringToLong(value);
3142 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3149 if (LocaleCompare(keyword,"width") == 0)
3151 frame_info.width=StringToLong(value);
3154 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3160 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3166 frame_info.x=(ssize_t) frame_info.width;
3167 frame_info.y=(ssize_t) frame_info.height;
3168 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3169 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3170 frame_image=FrameImage(msl_info->image[n],&frame_info,
3171 msl_info->image[n]->compose,msl_info->exception);
3172 if (frame_image == (Image *) NULL)
3174 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3175 msl_info->image[n]=frame_image;
3178 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3183 if (LocaleCompare((const char *) tag,"gamma") == 0)
3186 gamma[MagickPathExtent];
3194 if (msl_info->image[n] == (Image *) NULL)
3196 ThrowMSLException(OptionError,"NoImagesDefined",
3197 (const char *) tag);
3200 channel=UndefinedChannel;
3205 if (attributes != (const xmlChar **) NULL)
3206 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3208 keyword=(const char *) attributes[i++];
3209 attribute=InterpretImageProperties(msl_info->image_info[n],
3210 msl_info->attributes[n],(const char *) attributes[i],
3212 CloneString(&value,attribute);
3218 if (LocaleCompare(keyword,"blue") == 0)
3220 pixel.blue=StringToDouble(value,(char **) NULL);
3223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3230 if (LocaleCompare(keyword,"channel") == 0)
3232 option=ParseChannelOption(value);
3234 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3236 channel=(ChannelType) option;
3239 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3246 if (LocaleCompare(keyword,"gamma") == 0)
3248 (void) CopyMagickString(gamma,value,MagickPathExtent);
3251 if (LocaleCompare(keyword,"green") == 0)
3253 pixel.green=StringToDouble(value,(char **) NULL);
3256 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3263 if (LocaleCompare(keyword,"red") == 0)
3265 pixel.red=StringToDouble(value,(char **) NULL);
3268 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3274 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3281 (void) FormatLocaleString(gamma,MagickPathExtent,"%g,%g,%g",
3282 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3283 (void) GammaImage(msl_info->image[n],strtod(gamma,(char **) NULL),
3284 msl_info->exception);
3287 else if (LocaleCompare((const char *) tag,"get") == 0)
3289 if (msl_info->image[n] == (Image *) NULL)
3291 ThrowMSLException(OptionError,"NoImagesDefined",
3292 (const char *) tag);
3295 if (attributes == (const xmlChar **) NULL)
3297 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3299 keyword=(const char *) attributes[i++];
3300 CloneString(&value,(const char *) attributes[i]);
3301 (void) CopyMagickString(key,value,MagickPathExtent);
3307 if (LocaleCompare(keyword,"height") == 0)
3309 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
3310 (double) msl_info->image[n]->rows);
3311 (void) SetImageProperty(msl_info->attributes[n],key,value,
3315 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3320 if (LocaleCompare(keyword,"width") == 0)
3322 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
3323 (double) msl_info->image[n]->columns);
3324 (void) SetImageProperty(msl_info->attributes[n],key,value,
3328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3332 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3339 else if (LocaleCompare((const char *) tag, "group") == 0)
3341 msl_info->number_groups++;
3342 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3343 msl_info->group_info,msl_info->number_groups+1UL,
3344 sizeof(*msl_info->group_info));
3347 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3352 if (LocaleCompare((const char *) tag,"image") == 0)
3354 MSLPushImage(msl_info,(Image *) NULL);
3355 if (attributes == (const xmlChar **) NULL)
3357 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3359 keyword=(const char *) attributes[i++];
3360 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3361 msl_info->attributes[n],(const char *) attributes[i],exception));
3367 if (LocaleCompare(keyword,"color") == 0)
3372 (void) CopyMagickString(msl_info->image_info[n]->filename,
3373 "xc:",MagickPathExtent);
3374 (void) ConcatenateMagickString(msl_info->image_info[n]->
3375 filename,value,MagickPathExtent);
3376 next_image=ReadImage(msl_info->image_info[n],exception);
3377 CatchException(exception);
3378 if (next_image == (Image *) NULL)
3380 if (msl_info->image[n] == (Image *) NULL)
3381 msl_info->image[n]=next_image;
3388 Link image into image list.
3390 p=msl_info->image[n];
3391 while (p->next != (Image *) NULL)
3392 p=GetNextImageInList(p);
3393 next_image->previous=p;
3398 (void) SetMSLAttributes(msl_info,keyword,value);
3403 (void) SetMSLAttributes(msl_info,keyword,value);
3410 if (LocaleCompare((const char *) tag,"implode") == 0)
3418 if (msl_info->image[n] == (Image *) NULL)
3420 ThrowMSLException(OptionError,"NoImagesDefined",
3421 (const char *) tag);
3424 if (attributes != (const xmlChar **) NULL)
3425 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3427 keyword=(const char *) attributes[i++];
3428 attribute=InterpretImageProperties(msl_info->image_info[n],
3429 msl_info->attributes[n],(const char *) attributes[i],
3431 CloneString(&value,attribute);
3437 if (LocaleCompare(keyword,"amount") == 0)
3439 geometry_info.rho=StringToDouble(value,
3443 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3450 if (LocaleCompare(keyword,"geometry") == 0)
3452 flags=ParseGeometry(value,&geometry_info);
3453 if ((flags & SigmaValue) == 0)
3454 geometry_info.sigma=1.0;
3457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3463 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3469 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3470 msl_info->image[n]->interpolate,msl_info->exception);
3471 if (implode_image == (Image *) NULL)
3473 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3474 msl_info->image[n]=implode_image;
3477 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3482 if (LocaleCompare((const char *) tag,"label") == 0)
3484 if (LocaleCompare((const char *) tag, "level") == 0)
3487 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3489 if (msl_info->image[n] == (Image *) NULL)
3491 ThrowMSLException(OptionError,"NoImagesDefined",
3492 (const char *) tag);
3495 if (attributes == (const xmlChar **) NULL)
3497 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3499 keyword=(const char *) attributes[i++];
3500 CloneString(&value,(const char *) attributes[i]);
3501 (void) CopyMagickString(key,value,MagickPathExtent);
3507 if (LocaleCompare(keyword,"black") == 0)
3509 levelBlack = StringToDouble(value,(char **) NULL);
3512 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3518 if (LocaleCompare(keyword,"gamma") == 0)
3520 levelGamma = StringToDouble(value,(char **) NULL);
3523 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3529 if (LocaleCompare(keyword,"white") == 0)
3531 levelWhite = StringToDouble(value,(char **) NULL);
3534 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3539 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3546 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3547 msl_info->exception);
3554 if (LocaleCompare((const char *) tag,"magnify") == 0)
3562 if (msl_info->image[n] == (Image *) NULL)
3564 ThrowMSLException(OptionError,"NoImagesDefined",
3565 (const char *) tag);
3568 if (attributes != (const xmlChar **) NULL)
3569 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3571 keyword=(const char *) attributes[i++];
3572 attribute=InterpretImageProperties(msl_info->image_info[n],
3573 msl_info->attributes[n],(const char *) attributes[i],
3575 CloneString(&value,attribute);
3576 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3578 magnify_image=MagnifyImage(msl_info->image[n],
3579 msl_info->exception);
3580 if (magnify_image == (Image *) NULL)
3582 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3583 msl_info->image[n]=magnify_image;
3586 if (LocaleCompare((const char *) tag,"map") == 0)
3600 if (msl_info->image[n] == (Image *) NULL)
3602 ThrowMSLException(OptionError,"NoImagesDefined",
3603 (const char *) tag);
3606 affinity_image=NewImageList();
3608 if (attributes != (const xmlChar **) NULL)
3609 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3611 keyword=(const char *) attributes[i++];
3612 attribute=InterpretImageProperties(msl_info->image_info[n],
3613 msl_info->attributes[n],(const char *) attributes[i],
3615 CloneString(&value,attribute);
3621 if (LocaleCompare(keyword,"dither") == 0)
3623 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3626 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3628 dither=(MagickBooleanType) option;
3631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3638 if (LocaleCompare(keyword,"image") == 0)
3639 for (j=0; j < msl_info->n; j++)
3644 attribute=GetImageProperty(msl_info->attributes[j],"id",
3646 if ((attribute != (const char *) NULL) &&
3647 (LocaleCompare(attribute,value) == 0))
3649 affinity_image=CloneImage(msl_info->image[j],0,0,
3650 MagickFalse,exception);
3658 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3664 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3665 quantize_info->dither_method=dither != MagickFalse ?
3666 RiemersmaDitherMethod : NoDitherMethod;
3667 (void) RemapImages(quantize_info,msl_info->image[n],
3668 affinity_image,exception);
3669 quantize_info=DestroyQuantizeInfo(quantize_info);
3670 affinity_image=DestroyImage(affinity_image);
3673 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3685 Matte floodfill image.
3688 if (msl_info->image[n] == (Image *) NULL)
3690 ThrowMSLException(OptionError,"NoImagesDefined",
3691 (const char *) tag);
3694 SetGeometry(msl_info->image[n],&geometry);
3695 paint_method=FloodfillMethod;
3696 if (attributes != (const xmlChar **) NULL)
3697 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3699 keyword=(const char *) attributes[i++];
3700 attribute=InterpretImageProperties(msl_info->image_info[n],
3701 msl_info->attributes[n],(const char *) attributes[i],
3703 CloneString(&value,attribute);
3709 if (LocaleCompare(keyword,"bordercolor") == 0)
3711 (void) QueryColorCompliance(value,AllCompliance,
3713 paint_method=FillToBorderMethod;
3716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3723 if (LocaleCompare(keyword,"fuzz") == 0)
3725 msl_info->image[n]->fuzz=StringToDouble(value,
3729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3736 if (LocaleCompare(keyword,"geometry") == 0)
3738 flags=ParsePageGeometry(msl_info->image[n],value,
3739 &geometry,exception);
3740 if ((flags & HeightValue) == 0)
3741 geometry.height=geometry.width;
3742 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3743 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3747 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3754 if (LocaleCompare(keyword,"opacity") == 0)
3756 opacity=StringToDouble(value,(char **) NULL);
3759 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3766 if (LocaleCompare(keyword,"x") == 0)
3768 geometry.x=StringToLong(value);
3769 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3770 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3774 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3781 if (LocaleCompare(keyword,"y") == 0)
3783 geometry.y=StringToLong(value);
3784 (void) GetOneVirtualPixelInfo(msl_info->image[n],
3785 TileVirtualPixelMethod,geometry.x,geometry.y,&target,
3789 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3801 draw_info=CloneDrawInfo(msl_info->image_info[n],
3802 msl_info->draw_info[n]);
3803 draw_info->fill.alpha=ClampToQuantum(opacity);
3804 channel_mask=SetImageChannelMask(msl_info->image[n],AlphaChannel);
3805 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3806 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3807 MagickFalse : MagickTrue,msl_info->exception);
3808 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
3809 draw_info=DestroyDrawInfo(draw_info);
3812 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3818 Median-filter image.
3820 if (msl_info->image[n] == (Image *) NULL)
3822 ThrowMSLException(OptionError,"NoImagesDefined",
3823 (const char *) tag);
3826 if (attributes != (const xmlChar **) NULL)
3827 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3829 keyword=(const char *) attributes[i++];
3830 attribute=InterpretImageProperties(msl_info->image_info[n],
3831 msl_info->attributes[n],(const char *) attributes[i],
3833 CloneString(&value,attribute);
3839 if (LocaleCompare(keyword,"geometry") == 0)
3841 flags=ParseGeometry(value,&geometry_info);
3842 if ((flags & SigmaValue) == 0)
3843 geometry_info.sigma=1.0;
3846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3853 if (LocaleCompare(keyword,"radius") == 0)
3855 geometry_info.rho=StringToDouble(value,
3859 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3871 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3872 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3873 msl_info->exception);
3874 if (median_image == (Image *) NULL)
3876 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3877 msl_info->image[n]=median_image;
3880 if (LocaleCompare((const char *) tag,"minify") == 0)
3888 if (msl_info->image[n] == (Image *) NULL)
3890 ThrowMSLException(OptionError,"NoImagesDefined",
3891 (const char *) tag);
3894 if (attributes != (const xmlChar **) NULL)
3895 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3897 keyword=(const char *) attributes[i++];
3898 attribute=InterpretImageProperties(msl_info->image_info[n],
3899 msl_info->attributes[n],(const char *) attributes[i],
3901 CloneString(&value,attribute);
3902 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3904 minify_image=MinifyImage(msl_info->image[n],
3905 msl_info->exception);
3906 if (minify_image == (Image *) NULL)
3908 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3909 msl_info->image[n]=minify_image;
3912 if (LocaleCompare((const char *) tag,"msl") == 0 )
3914 if (LocaleCompare((const char *) tag,"modulate") == 0)
3917 modulate[MagickPathExtent];
3922 if (msl_info->image[n] == (Image *) NULL)
3924 ThrowMSLException(OptionError,"NoImagesDefined",
3925 (const char *) tag);
3928 geometry_info.rho=100.0;
3929 geometry_info.sigma=100.0;
3930 geometry_info.xi=100.0;
3931 if (attributes != (const xmlChar **) NULL)
3932 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3934 keyword=(const char *) attributes[i++];
3935 attribute=InterpretImageProperties(msl_info->image_info[n],
3936 msl_info->attributes[n],(const char *) attributes[i],
3938 CloneString(&value,attribute);
3944 if (LocaleCompare(keyword,"blackness") == 0)
3946 geometry_info.rho=StringToDouble(value,
3950 if (LocaleCompare(keyword,"brightness") == 0)
3952 geometry_info.rho=StringToDouble(value,
3956 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3963 if (LocaleCompare(keyword,"factor") == 0)
3965 flags=ParseGeometry(value,&geometry_info);
3968 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3975 if (LocaleCompare(keyword,"hue") == 0)
3977 geometry_info.xi=StringToDouble(value,
3981 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3988 if (LocaleCompare(keyword,"lightness") == 0)
3990 geometry_info.rho=StringToDouble(value,
3994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4001 if (LocaleCompare(keyword,"saturation") == 0)
4003 geometry_info.sigma=StringToDouble(value,
4007 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4014 if (LocaleCompare(keyword,"whiteness") == 0)
4016 geometry_info.sigma=StringToDouble(value,
4020 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4032 (void) FormatLocaleString(modulate,MagickPathExtent,"%g,%g,%g",
4033 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4034 (void) ModulateImage(msl_info->image[n],modulate,
4035 msl_info->exception);
4038 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4043 if (LocaleCompare((const char *) tag,"negate") == 0)
4051 if (msl_info->image[n] == (Image *) NULL)
4053 ThrowMSLException(OptionError,"NoImagesDefined",
4054 (const char *) tag);
4058 if (attributes != (const xmlChar **) NULL)
4059 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4061 keyword=(const char *) attributes[i++];
4062 attribute=InterpretImageProperties(msl_info->image_info[n],
4063 msl_info->attributes[n],(const char *) attributes[i],
4065 CloneString(&value,attribute);
4071 if (LocaleCompare(keyword,"channel") == 0)
4073 option=ParseChannelOption(value);
4075 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4077 channel=(ChannelType) option;
4080 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4087 if (LocaleCompare(keyword,"gray") == 0)
4089 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4092 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4094 gray=(MagickBooleanType) option;
4097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4109 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4110 (void) NegateImage(msl_info->image[n],gray,
4111 msl_info->exception);
4112 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4115 if (LocaleCompare((const char *) tag,"normalize") == 0)
4120 if (msl_info->image[n] == (Image *) NULL)
4122 ThrowMSLException(OptionError,"NoImagesDefined",
4123 (const char *) tag);
4126 if (attributes != (const xmlChar **) NULL)
4127 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4129 keyword=(const char *) attributes[i++];
4130 attribute=InterpretImageProperties(msl_info->image_info[n],
4131 msl_info->attributes[n],(const char *) attributes[i],
4133 CloneString(&value,attribute);
4139 if (LocaleCompare(keyword,"channel") == 0)
4141 option=ParseChannelOption(value);
4143 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4145 channel=(ChannelType) option;
4148 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4154 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4160 (void) NormalizeImage(msl_info->image[n],
4161 msl_info->exception);
4164 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4169 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4177 if (msl_info->image[n] == (Image *) NULL)
4179 ThrowMSLException(OptionError,"NoImagesDefined",
4180 (const char *) tag);
4183 if (attributes != (const xmlChar **) NULL)
4184 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4186 keyword=(const char *) attributes[i++];
4187 attribute=InterpretImageProperties(msl_info->image_info[n],
4188 msl_info->attributes[n],(const char *) attributes[i],
4190 CloneString(&value,attribute);
4196 if (LocaleCompare(keyword,"geometry") == 0)
4198 flags=ParseGeometry(value,&geometry_info);
4199 if ((flags & SigmaValue) == 0)
4200 geometry_info.sigma=1.0;
4203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4210 if (LocaleCompare(keyword,"radius") == 0)
4212 geometry_info.rho=StringToDouble(value,
4216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4222 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4228 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4229 geometry_info.sigma,msl_info->exception);
4230 if (paint_image == (Image *) NULL)
4232 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4233 msl_info->image[n]=paint_image;
4236 if (LocaleCompare((const char *) tag,"opaque") == 0)
4245 if (msl_info->image[n] == (Image *) NULL)
4247 ThrowMSLException(OptionError,"NoImagesDefined",
4248 (const char *) tag);
4251 (void) QueryColorCompliance("none",AllCompliance,&target,
4253 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
4255 if (attributes != (const xmlChar **) NULL)
4256 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4258 keyword=(const char *) attributes[i++];
4259 attribute=InterpretImageProperties(msl_info->image_info[n],
4260 msl_info->attributes[n],(const char *) attributes[i],
4262 CloneString(&value,attribute);
4268 if (LocaleCompare(keyword,"channel") == 0)
4270 option=ParseChannelOption(value);
4272 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4274 channel=(ChannelType) option;
4277 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4284 if (LocaleCompare(keyword,"fill") == 0)
4286 (void) QueryColorCompliance(value,AllCompliance,
4287 &fill_color,exception);
4290 if (LocaleCompare(keyword,"fuzz") == 0)
4292 msl_info->image[n]->fuzz=StringToDouble(value,
4296 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4302 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4308 channel_mask=SetImageChannelMask(msl_info->image[n],channel);
4309 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4310 MagickFalse,msl_info->exception);
4311 (void) SetPixelChannelMask(msl_info->image[n],channel_mask);
4314 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4319 if (LocaleCompare((const char *) tag,"print") == 0)
4321 if (attributes == (const xmlChar **) NULL)
4323 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4325 keyword=(const char *) attributes[i++];
4326 attribute=InterpretImageProperties(msl_info->image_info[n],
4327 msl_info->attributes[n],(const char *) attributes[i],
4329 CloneString(&value,attribute);
4335 if (LocaleCompare(keyword,"output") == 0)
4337 (void) FormatLocaleFile(stdout,"%s",value);
4340 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4345 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4352 if (LocaleCompare((const char *) tag, "profile") == 0)
4354 if (msl_info->image[n] == (Image *) NULL)
4356 ThrowMSLException(OptionError,"NoImagesDefined",
4357 (const char *) tag);
4360 if (attributes == (const xmlChar **) NULL)
4362 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4376 keyword=(const char *) attributes[i++];
4377 attribute=InterpretImageProperties(msl_info->image_info[n],
4378 msl_info->attributes[n],(const char *) attributes[i],
4380 CloneString(&value,attribute);
4381 if (*keyword == '!')
4384 Remove a profile from the image.
4386 (void) ProfileImage(msl_info->image[n],keyword,
4387 (const unsigned char *) NULL,0,exception);
4391 Associate a profile with the image.
4393 profile_info=CloneImageInfo(msl_info->image_info[n]);
4394 profile=GetImageProfile(msl_info->image[n],"iptc");
4395 if (profile != (StringInfo *) NULL)
4396 profile_info->profile=(void *) CloneStringInfo(profile);
4397 profile_image=GetImageCache(profile_info,keyword,exception);
4398 profile_info=DestroyImageInfo(profile_info);
4399 if (profile_image == (Image *) NULL)
4402 name[MagickPathExtent],
4403 filename[MagickPathExtent];
4411 (void) CopyMagickString(filename,keyword,MagickPathExtent);
4412 (void) CopyMagickString(name,keyword,MagickPathExtent);
4413 for (p=filename; *p != '\0'; p++)
4414 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4415 (IsPathAccessible(keyword) == MagickFalse))
4421 Look for profile name (e.g. name:profile).
4423 (void) CopyMagickString(name,filename,(size_t)
4425 for (q=filename; *q != '\0'; q++)
4429 profile=FileToStringInfo(filename,~0UL,exception);
4430 if (profile != (StringInfo *) NULL)
4432 (void) ProfileImage(msl_info->image[n],name,
4433 GetStringInfoDatum(profile),(size_t)
4434 GetStringInfoLength(profile),exception);
4435 profile=DestroyStringInfo(profile);
4439 ResetImageProfileIterator(profile_image);
4440 name=GetNextImageProfile(profile_image);
4441 while (name != (const char *) NULL)
4443 profile=GetImageProfile(profile_image,name);
4444 if (profile != (StringInfo *) NULL)
4445 (void) ProfileImage(msl_info->image[n],name,
4446 GetStringInfoDatum(profile),(size_t)
4447 GetStringInfoLength(profile),exception);
4448 name=GetNextImageProfile(profile_image);
4450 profile_image=DestroyImage(profile_image);
4454 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4459 if (LocaleCompare((const char *) tag,"quantize") == 0)
4467 if (msl_info->image[n] == (Image *) NULL)
4469 ThrowMSLException(OptionError,"NoImagesDefined",
4470 (const char *) tag);
4473 GetQuantizeInfo(&quantize_info);
4474 if (attributes != (const xmlChar **) NULL)
4475 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4477 keyword=(const char *) attributes[i++];
4478 attribute=InterpretImageProperties(msl_info->image_info[n],
4479 msl_info->attributes[n],(const char *) attributes[i],
4481 CloneString(&value,attribute);
4487 if (LocaleCompare(keyword,"colors") == 0)
4489 quantize_info.number_colors=StringToLong(value);
4492 if (LocaleCompare(keyword,"colorspace") == 0)
4494 option=ParseCommandOption(MagickColorspaceOptions,
4497 ThrowMSLException(OptionError,
4498 "UnrecognizedColorspaceType",value);
4499 quantize_info.colorspace=(ColorspaceType) option;
4502 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4509 if (LocaleCompare(keyword,"dither") == 0)
4511 option=ParseCommandOption(MagickDitherOptions,MagickFalse,
4514 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4516 quantize_info.dither_method=(DitherMethod) option;
4519 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4526 if (LocaleCompare(keyword,"measure") == 0)
4528 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4531 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4533 quantize_info.measure_error=(MagickBooleanType) option;
4536 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4543 if (LocaleCompare(keyword,"treedepth") == 0)
4545 quantize_info.tree_depth=StringToLong(value);
4548 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4554 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4560 (void) QuantizeImage(&quantize_info,msl_info->image[n],exception);
4563 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4566 text[MagickPathExtent];
4577 draw_info=CloneDrawInfo(msl_info->image_info[n],
4578 msl_info->draw_info[n]);
4580 current=draw_info->affine;
4581 GetAffineMatrix(&affine);
4582 if (attributes != (const xmlChar **) NULL)
4583 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4585 keyword=(const char *) attributes[i++];
4586 attribute=InterpretImageProperties(msl_info->image_info[n],
4587 msl_info->attributes[n],(const char *) attributes[i],
4589 CloneString(&value,attribute);
4595 if (LocaleCompare(keyword,"affine") == 0)
4601 draw_info->affine.sx=StringToDouble(p,&p);
4604 draw_info->affine.rx=StringToDouble(p,&p);
4607 draw_info->affine.ry=StringToDouble(p,&p);
4610 draw_info->affine.sy=StringToDouble(p,&p);
4613 draw_info->affine.tx=StringToDouble(p,&p);
4616 draw_info->affine.ty=StringToDouble(p,&p);
4619 if (LocaleCompare(keyword,"align") == 0)
4621 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4624 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4626 draw_info->align=(AlignType) option;
4629 if (LocaleCompare(keyword,"antialias") == 0)
4631 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4634 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4636 draw_info->stroke_antialias=(MagickBooleanType) option;
4637 draw_info->text_antialias=(MagickBooleanType) option;
4640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4647 if (LocaleCompare(keyword,"density") == 0)
4649 CloneString(&draw_info->density,value);
4652 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4659 if (LocaleCompare(keyword,"encoding") == 0)
4661 CloneString(&draw_info->encoding,value);
4664 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4671 if (LocaleCompare(keyword, "fill") == 0)
4673 (void) QueryColorCompliance(value,AllCompliance,
4674 &draw_info->fill,exception);
4677 if (LocaleCompare(keyword,"family") == 0)
4679 CloneString(&draw_info->family,value);
4682 if (LocaleCompare(keyword,"font") == 0)
4684 CloneString(&draw_info->font,value);
4687 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4694 if (LocaleCompare(keyword,"geometry") == 0)
4696 flags=ParsePageGeometry(msl_info->image[n],value,
4697 &geometry,exception);
4698 if ((flags & HeightValue) == 0)
4699 geometry.height=geometry.width;
4702 if (LocaleCompare(keyword,"gravity") == 0)
4704 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4707 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4709 draw_info->gravity=(GravityType) option;
4712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4719 if (LocaleCompare(keyword,"pointsize") == 0)
4721 draw_info->pointsize=StringToDouble(value,
4725 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4732 if (LocaleCompare(keyword,"rotate") == 0)
4734 angle=StringToDouble(value,(char **) NULL);
4735 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4736 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4737 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4738 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4741 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4748 if (LocaleCompare(keyword,"scale") == 0)
4750 flags=ParseGeometry(value,&geometry_info);
4751 if ((flags & SigmaValue) == 0)
4752 geometry_info.sigma=1.0;
4753 affine.sx=geometry_info.rho;
4754 affine.sy=geometry_info.sigma;
4757 if (LocaleCompare(keyword,"skewX") == 0)
4759 angle=StringToDouble(value,(char **) NULL);
4760 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4763 if (LocaleCompare(keyword,"skewY") == 0)
4765 angle=StringToDouble(value,(char **) NULL);
4766 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4769 if (LocaleCompare(keyword,"stretch") == 0)
4771 option=ParseCommandOption(MagickStretchOptions,
4774 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4776 draw_info->stretch=(StretchType) option;
4779 if (LocaleCompare(keyword, "stroke") == 0)
4781 (void) QueryColorCompliance(value,AllCompliance,
4782 &draw_info->stroke,exception);
4785 if (LocaleCompare(keyword,"strokewidth") == 0)
4787 draw_info->stroke_width=StringToLong(value);
4790 if (LocaleCompare(keyword,"style") == 0)
4792 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4795 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4797 draw_info->style=(StyleType) option;
4800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4807 if (LocaleCompare(keyword,"text") == 0)
4809 CloneString(&draw_info->text,value);
4812 if (LocaleCompare(keyword,"translate") == 0)
4814 flags=ParseGeometry(value,&geometry_info);
4815 if ((flags & SigmaValue) == 0)
4816 geometry_info.sigma=1.0;
4817 affine.tx=geometry_info.rho;
4818 affine.ty=geometry_info.sigma;
4821 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4828 if (LocaleCompare(keyword, "undercolor") == 0)
4830 (void) QueryColorCompliance(value,AllCompliance,
4831 &draw_info->undercolor,exception);
4834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4841 if (LocaleCompare(keyword,"weight") == 0)
4843 draw_info->weight=StringToLong(value);
4846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4853 if (LocaleCompare(keyword,"x") == 0)
4855 geometry.x=StringToLong(value);
4858 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4865 if (LocaleCompare(keyword,"y") == 0)
4867 geometry.y=StringToLong(value);
4870 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4876 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4882 (void) FormatLocaleString(text,MagickPathExtent,
4883 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4884 geometry.height,(double) geometry.x,(double) geometry.y);
4885 CloneString(&draw_info->geometry,text);
4886 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4887 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4888 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4889 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4890 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4892 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4894 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4895 msl_info->exception);
4896 if (status != MagickFalse)
4901 image=msl_info->attributes[n];
4902 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4903 "%g",metrics.pixels_per_em.x);
4904 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4905 "%g",metrics.pixels_per_em.y);
4906 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4908 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4910 FormatImageProperty(image,"msl:font-metrics.width","%g",
4912 FormatImageProperty(image,"msl:font-metrics.height","%g",
4914 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4915 metrics.max_advance);
4916 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4918 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4920 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4922 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4924 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4926 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4929 draw_info=DestroyDrawInfo(draw_info);
4932 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4937 if (LocaleCompare((const char *) tag,"raise") == 0)
4945 if (msl_info->image[n] == (Image *) NULL)
4947 ThrowMSLException(OptionError,"NoImagesDefined",
4948 (const char *) tag);
4952 SetGeometry(msl_info->image[n],&geometry);
4953 if (attributes != (const xmlChar **) NULL)
4954 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4956 keyword=(const char *) attributes[i++];
4957 attribute=InterpretImageProperties(msl_info->image_info[n],
4958 msl_info->attributes[n],(const char *) attributes[i],
4960 CloneString(&value,attribute);
4966 if (LocaleCompare(keyword,"geometry") == 0)
4968 flags=ParsePageGeometry(msl_info->image[n],value,
4969 &geometry,exception);
4970 if ((flags & HeightValue) == 0)
4971 geometry.height=geometry.width;
4974 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4981 if (LocaleCompare(keyword,"height") == 0)
4983 geometry.height=StringToLong(value);
4986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4993 if (LocaleCompare(keyword,"raise") == 0)
4995 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4998 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5000 raise=(MagickBooleanType) option;
5003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5010 if (LocaleCompare(keyword,"width") == 0)
5012 geometry.width=StringToLong(value);
5015 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5021 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5027 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5028 msl_info->exception);
5031 if (LocaleCompare((const char *) tag,"read") == 0)
5033 if (attributes == (const xmlChar **) NULL)
5035 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5037 keyword=(const char *) attributes[i++];
5038 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5039 msl_info->attributes[n],(const char *) attributes[i],exception));
5045 if (LocaleCompare(keyword,"filename") == 0)
5050 if (value == (char *) NULL)
5052 (void) CopyMagickString(msl_info->image_info[n]->filename,
5053 value,MagickPathExtent);
5054 image=ReadImage(msl_info->image_info[n],exception);
5055 CatchException(exception);
5056 if (image == (Image *) NULL)
5058 AppendImageToList(&msl_info->image[n],image);
5061 (void) SetMSLAttributes(msl_info,keyword,value);
5066 (void) SetMSLAttributes(msl_info,keyword,value);
5073 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5081 if (msl_info->image[n] == (Image *) NULL)
5083 ThrowMSLException(OptionError,"NoImagesDefined",
5084 (const char *) tag);
5087 if (attributes != (const xmlChar **) NULL)
5088 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5090 keyword=(const char *) attributes[i++];
5091 attribute=InterpretImageProperties(msl_info->image_info[n],
5092 msl_info->attributes[n],(const char *) attributes[i],
5094 CloneString(&value,attribute);
5100 if (LocaleCompare(keyword,"geometry") == 0)
5102 flags=ParseGeometry(value,&geometry_info);
5103 if ((flags & SigmaValue) == 0)
5104 geometry_info.sigma=1.0;
5107 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5114 if (LocaleCompare(keyword,"radius") == 0)
5116 geometry_info.rho=StringToDouble(value,
5120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5126 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5132 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5133 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5134 msl_info->exception);
5135 if (paint_image == (Image *) NULL)
5137 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5138 msl_info->image[n]=paint_image;
5141 else if (LocaleCompare((const char *) tag,"repage") == 0)
5143 /* init the values */
5144 width=msl_info->image[n]->page.width;
5145 height=msl_info->image[n]->page.height;
5146 x=msl_info->image[n]->page.x;
5147 y=msl_info->image[n]->page.y;
5149 if (msl_info->image[n] == (Image *) NULL)
5151 ThrowMSLException(OptionError,"NoImagesDefined",
5152 (const char *) tag);
5155 if (attributes == (const xmlChar **) NULL)
5157 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5159 keyword=(const char *) attributes[i++];
5160 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5161 msl_info->attributes[n],(const char *) attributes[i],exception));
5167 if (LocaleCompare(keyword,"geometry") == 0)
5175 flags=ParseAbsoluteGeometry(value,&geometry);
5176 if ((flags & WidthValue) != 0)
5178 if ((flags & HeightValue) == 0)
5179 geometry.height=geometry.width;
5180 width=geometry.width;
5181 height=geometry.height;
5183 if ((flags & AspectValue) != 0)
5185 if ((flags & XValue) != 0)
5187 if ((flags & YValue) != 0)
5192 if ((flags & XValue) != 0)
5195 if ((width == 0) && (geometry.x > 0))
5196 width=msl_info->image[n]->columns+geometry.x;
5198 if ((flags & YValue) != 0)
5201 if ((height == 0) && (geometry.y > 0))
5202 height=msl_info->image[n]->rows+geometry.y;
5207 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5213 if (LocaleCompare(keyword,"height") == 0)
5215 height = StringToLong( value );
5218 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5224 if (LocaleCompare(keyword,"width") == 0)
5226 width = StringToLong( value );
5229 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5235 if (LocaleCompare(keyword,"x") == 0)
5237 x = StringToLong( value );
5240 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5246 if (LocaleCompare(keyword,"y") == 0)
5248 y = StringToLong( value );
5251 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5256 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5262 msl_info->image[n]->page.width=width;
5263 msl_info->image[n]->page.height=height;
5264 msl_info->image[n]->page.x=x;
5265 msl_info->image[n]->page.y=y;
5268 else if (LocaleCompare((const char *) tag,"resample") == 0)
5274 if (msl_info->image[n] == (Image *) NULL)
5276 ThrowMSLException(OptionError,"NoImagesDefined",
5277 (const char *) tag);
5280 if (attributes == (const xmlChar **) NULL)
5282 x_resolution=DefaultResolution;
5283 y_resolution=DefaultResolution;
5284 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5286 keyword=(const char *) attributes[i++];
5287 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5288 msl_info->attributes[n],(const char *) attributes[i],exception));
5294 if (LocaleCompare(keyword,"geometry") == 0)
5299 flags=ParseGeometry(value,&geometry_info);
5300 if ((flags & SigmaValue) == 0)
5301 geometry_info.sigma*=geometry_info.rho;
5302 x_resolution=geometry_info.rho;
5303 y_resolution=geometry_info.sigma;
5306 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5312 if (LocaleCompare(keyword,"x-resolution") == 0)
5314 x_resolution=StringToDouble(value,(char **) NULL);
5317 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5323 if (LocaleCompare(keyword,"y-resolution") == 0)
5325 y_resolution=StringToDouble(value,(char **) NULL);
5328 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5333 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5349 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5351 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5352 (factor*(msl_info->image[n]->resolution.x == 0.0 ? DefaultResolution :
5353 msl_info->image[n]->resolution.x))+0.5);
5354 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5355 (factor*(msl_info->image[n]->resolution.y == 0.0 ? DefaultResolution :
5356 msl_info->image[n]->resolution.y))+0.5);
5357 resample_image=ResizeImage(msl_info->image[n],width,height,
5358 msl_info->image[n]->filter,msl_info->exception);
5359 if (resample_image == (Image *) NULL)
5361 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5362 msl_info->image[n]=resample_image;
5366 if (LocaleCompare((const char *) tag,"resize") == 0)
5377 if (msl_info->image[n] == (Image *) NULL)
5379 ThrowMSLException(OptionError,"NoImagesDefined",
5380 (const char *) tag);
5383 filter=UndefinedFilter;
5384 if (attributes != (const xmlChar **) NULL)
5385 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5387 keyword=(const char *) attributes[i++];
5388 attribute=InterpretImageProperties(msl_info->image_info[n],
5389 msl_info->attributes[n],(const char *) attributes[i],
5391 CloneString(&value,attribute);
5397 if (LocaleCompare(keyword,"filter") == 0)
5399 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5402 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5404 filter=(FilterType) option;
5407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5414 if (LocaleCompare(keyword,"geometry") == 0)
5416 flags=ParseRegionGeometry(msl_info->image[n],value,
5417 &geometry,exception);
5420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5427 if (LocaleCompare(keyword,"height") == 0)
5429 geometry.height=StringToUnsignedLong(value);
5432 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5439 if (LocaleCompare(keyword,"width") == 0)
5441 geometry.width=StringToLong(value);
5444 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5450 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5456 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5457 geometry.height,filter,msl_info->exception);
5458 if (resize_image == (Image *) NULL)
5460 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5461 msl_info->image[n]=resize_image;
5464 if (LocaleCompare((const char *) tag,"roll") == 0)
5472 if (msl_info->image[n] == (Image *) NULL)
5474 ThrowMSLException(OptionError,"NoImagesDefined",
5475 (const char *) tag);
5478 SetGeometry(msl_info->image[n],&geometry);
5479 if (attributes != (const xmlChar **) NULL)
5480 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5482 keyword=(const char *) attributes[i++];
5483 attribute=InterpretImageProperties(msl_info->image_info[n],
5484 msl_info->attributes[n],(const char *) attributes[i],
5486 CloneString(&value,attribute);
5492 if (LocaleCompare(keyword,"geometry") == 0)
5494 flags=ParsePageGeometry(msl_info->image[n],value,
5495 &geometry,exception);
5496 if ((flags & HeightValue) == 0)
5497 geometry.height=geometry.width;
5500 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5507 if (LocaleCompare(keyword,"x") == 0)
5509 geometry.x=StringToLong(value);
5512 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5519 if (LocaleCompare(keyword,"y") == 0)
5521 geometry.y=StringToLong(value);
5524 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5530 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5536 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5537 msl_info->exception);
5538 if (roll_image == (Image *) NULL)
5540 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5541 msl_info->image[n]=roll_image;
5544 else if (LocaleCompare((const char *) tag,"roll") == 0)
5546 /* init the values */
5547 width=msl_info->image[n]->columns;
5548 height=msl_info->image[n]->rows;
5551 if (msl_info->image[n] == (Image *) NULL)
5553 ThrowMSLException(OptionError,"NoImagesDefined",
5554 (const char *) tag);
5557 if (attributes == (const xmlChar **) NULL)
5559 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5561 keyword=(const char *) attributes[i++];
5562 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5563 msl_info->attributes[n],(const char *) attributes[i],exception));
5569 if (LocaleCompare(keyword,"geometry") == 0)
5571 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5574 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5580 if (LocaleCompare(keyword,"x") == 0)
5582 x = StringToLong( value );
5585 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5591 if (LocaleCompare(keyword,"y") == 0)
5593 y = StringToLong( value );
5596 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5601 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5614 newImage=RollImage(msl_info->image[n], x, y, msl_info->exception);
5615 if (newImage == (Image *) NULL)
5617 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5618 msl_info->image[n]=newImage;
5623 if (LocaleCompare((const char *) tag,"rotate") == 0)
5631 if (msl_info->image[n] == (Image *) NULL)
5633 ThrowMSLException(OptionError,"NoImagesDefined",
5634 (const char *) tag);
5637 if (attributes != (const xmlChar **) NULL)
5638 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5640 keyword=(const char *) attributes[i++];
5641 attribute=InterpretImageProperties(msl_info->image_info[n],
5642 msl_info->attributes[n],(const char *) attributes[i],
5644 CloneString(&value,attribute);
5650 if (LocaleCompare(keyword,"degrees") == 0)
5652 geometry_info.rho=StringToDouble(value,
5656 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5663 if (LocaleCompare(keyword,"geometry") == 0)
5665 flags=ParseGeometry(value,&geometry_info);
5666 if ((flags & SigmaValue) == 0)
5667 geometry_info.sigma=1.0;
5670 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5676 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5682 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5683 msl_info->exception);
5684 if (rotate_image == (Image *) NULL)
5686 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5687 msl_info->image[n]=rotate_image;
5690 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5692 /* init the values */
5695 if (msl_info->image[n] == (Image *) NULL)
5697 ThrowMSLException(OptionError,"NoImagesDefined",
5698 (const char *) tag);
5701 if (attributes == (const xmlChar **) NULL)
5703 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5705 keyword=(const char *) attributes[i++];
5706 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5707 msl_info->attributes[n],(const char *) attributes[i],exception));
5713 if (LocaleCompare(keyword,"degrees") == 0)
5715 degrees = StringToDouble(value,(char **) NULL);
5718 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5723 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5736 newImage=RotateImage(msl_info->image[n], degrees, msl_info->exception);
5737 if (newImage == (Image *) NULL)
5739 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5740 msl_info->image[n]=newImage;
5745 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5750 if (LocaleCompare((const char *) tag,"sample") == 0)
5758 if (msl_info->image[n] == (Image *) NULL)
5760 ThrowMSLException(OptionError,"NoImagesDefined",
5761 (const char *) tag);
5764 if (attributes != (const xmlChar **) NULL)
5765 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5767 keyword=(const char *) attributes[i++];
5768 attribute=InterpretImageProperties(msl_info->image_info[n],
5769 msl_info->attributes[n],(const char *) attributes[i],
5771 CloneString(&value,attribute);
5777 if (LocaleCompare(keyword,"geometry") == 0)
5779 flags=ParseRegionGeometry(msl_info->image[n],value,
5780 &geometry,exception);
5783 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5790 if (LocaleCompare(keyword,"height") == 0)
5792 geometry.height=StringToUnsignedLong(value);
5795 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5802 if (LocaleCompare(keyword,"width") == 0)
5804 geometry.width=StringToLong(value);
5807 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5819 sample_image=SampleImage(msl_info->image[n],geometry.width,
5820 geometry.height,msl_info->exception);
5821 if (sample_image == (Image *) NULL)
5823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5824 msl_info->image[n]=sample_image;
5827 if (LocaleCompare((const char *) tag,"scale") == 0)
5835 if (msl_info->image[n] == (Image *) NULL)
5837 ThrowMSLException(OptionError,"NoImagesDefined",
5838 (const char *) tag);
5841 if (attributes != (const xmlChar **) NULL)
5842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5844 keyword=(const char *) attributes[i++];
5845 attribute=InterpretImageProperties(msl_info->image_info[n],
5846 msl_info->attributes[n],(const char *) attributes[i],
5848 CloneString(&value,attribute);
5854 if (LocaleCompare(keyword,"geometry") == 0)
5856 flags=ParseRegionGeometry(msl_info->image[n],value,
5857 &geometry,exception);
5860 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5867 if (LocaleCompare(keyword,"height") == 0)
5869 geometry.height=StringToUnsignedLong(value);
5872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5879 if (LocaleCompare(keyword,"width") == 0)
5881 geometry.width=StringToLong(value);
5884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5896 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5897 geometry.height,msl_info->exception);
5898 if (scale_image == (Image *) NULL)
5900 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5901 msl_info->image[n]=scale_image;
5904 if (LocaleCompare((const char *) tag,"segment") == 0)
5915 if (msl_info->image[n] == (Image *) NULL)
5917 ThrowMSLException(OptionError,"NoImagesDefined",
5918 (const char *) tag);
5921 geometry_info.rho=1.0;
5922 geometry_info.sigma=1.5;
5923 colorspace=sRGBColorspace;
5924 verbose=MagickFalse;
5925 if (attributes != (const xmlChar **) NULL)
5926 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5928 keyword=(const char *) attributes[i++];
5929 attribute=InterpretImageProperties(msl_info->image_info[n],
5930 msl_info->attributes[n],(const char *) attributes[i],
5932 CloneString(&value,attribute);
5938 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5940 geometry_info.rho=StringToDouble(value,
5944 if (LocaleCompare(keyword,"colorspace") == 0)
5946 option=ParseCommandOption(MagickColorspaceOptions,
5949 ThrowMSLException(OptionError,
5950 "UnrecognizedColorspaceType",value);
5951 colorspace=(ColorspaceType) option;
5954 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5961 if (LocaleCompare(keyword,"geometry") == 0)
5963 flags=ParseGeometry(value,&geometry_info);
5964 if ((flags & SigmaValue) == 0)
5965 geometry_info.sigma=1.5;
5968 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5975 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5977 geometry_info.sigma=StringToDouble(value,
5981 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5987 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5993 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5994 geometry_info.rho,geometry_info.sigma,exception);
5997 else if (LocaleCompare((const char *) tag, "set") == 0)
5999 if (msl_info->image[n] == (Image *) NULL)
6001 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6005 if (attributes == (const xmlChar **) NULL)
6007 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6009 keyword=(const char *) attributes[i++];
6010 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6011 msl_info->attributes[n],(const char *) attributes[i],exception));
6017 if (LocaleCompare(keyword,"clip-mask") == 0)
6019 for (j=0; j < msl_info->n; j++)
6024 property=GetImageProperty(msl_info->attributes[j],"id",
6026 if (LocaleCompare(property,value) == 0)
6028 SetImageMask(msl_info->image[n],ReadPixelMask,
6029 msl_info->image[j],exception);
6035 if (LocaleCompare(keyword,"clip-path") == 0)
6037 for (j=0; j < msl_info->n; j++)
6042 property=GetImageProperty(msl_info->attributes[j],"id",
6044 if (LocaleCompare(property,value) == 0)
6046 SetImageMask(msl_info->image[n],ReadPixelMask,
6047 msl_info->image[j],exception);
6053 if (LocaleCompare(keyword,"colorspace") == 0)
6058 colorspace=(ColorspaceType) ParseCommandOption(
6059 MagickColorspaceOptions,MagickFalse,value);
6061 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6063 (void) TransformImageColorspace(msl_info->image[n],
6064 (ColorspaceType) colorspace,exception);
6067 (void) SetMSLAttributes(msl_info,keyword,value);
6068 (void) SetImageProperty(msl_info->image[n],keyword,value,
6075 if (LocaleCompare(keyword,"density") == 0)
6077 flags=ParseGeometry(value,&geometry_info);
6078 msl_info->image[n]->resolution.x=geometry_info.rho;
6079 msl_info->image[n]->resolution.y=geometry_info.sigma;
6080 if ((flags & SigmaValue) == 0)
6081 msl_info->image[n]->resolution.y=
6082 msl_info->image[n]->resolution.x;
6085 (void) SetMSLAttributes(msl_info,keyword,value);
6086 (void) SetImageProperty(msl_info->image[n],keyword,value,
6093 if (LocaleCompare(keyword, "opacity") == 0)
6095 ssize_t opac = OpaqueAlpha,
6096 len = (ssize_t) strlen( value );
6098 if (value[len-1] == '%') {
6100 (void) CopyMagickString(tmp,value,len);
6101 opac = StringToLong( tmp );
6102 opac = (int)(QuantumRange * ((float)opac/100));
6104 opac = StringToLong( value );
6105 (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
6109 (void) SetMSLAttributes(msl_info,keyword,value);
6110 (void) SetImageProperty(msl_info->image[n],keyword,value,
6111 msl_info->exception);
6117 if (LocaleCompare(keyword, "page") == 0)
6120 page[MagickPathExtent];
6131 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6132 image_option=GetImageArtifact(msl_info->image[n],"page");
6133 if (image_option != (const char *) NULL)
6134 flags=ParseAbsoluteGeometry(image_option,&geometry);
6135 flags=ParseAbsoluteGeometry(value,&geometry);
6136 (void) FormatLocaleString(page,MagickPathExtent,"%.20gx%.20g",
6137 (double) geometry.width,(double) geometry.height);
6138 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6139 (void) FormatLocaleString(page,MagickPathExtent,
6140 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6141 (double) geometry.height,(double) geometry.x,(double)
6143 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6144 msl_info->image_info[n]->page=GetPageGeometry(page);
6147 (void) SetMSLAttributes(msl_info,keyword,value);
6148 (void) SetImageProperty(msl_info->image[n],keyword,value,
6149 msl_info->exception);
6154 (void) SetMSLAttributes(msl_info,keyword,value);
6155 (void) SetImageProperty(msl_info->image[n],keyword,value,
6156 msl_info->exception);
6163 if (LocaleCompare((const char *) tag,"shade") == 0)
6174 if (msl_info->image[n] == (Image *) NULL)
6176 ThrowMSLException(OptionError,"NoImagesDefined",
6177 (const char *) tag);
6181 if (attributes != (const xmlChar **) NULL)
6182 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6184 keyword=(const char *) attributes[i++];
6185 attribute=InterpretImageProperties(msl_info->image_info[n],
6186 msl_info->attributes[n],(const char *) attributes[i],
6188 CloneString(&value,attribute);
6194 if (LocaleCompare(keyword,"azimuth") == 0)
6196 geometry_info.rho=StringToDouble(value,
6200 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6207 if (LocaleCompare(keyword,"elevation") == 0)
6209 geometry_info.sigma=StringToDouble(value,
6213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6220 if (LocaleCompare(keyword,"geometry") == 0)
6222 flags=ParseGeometry(value,&geometry_info);
6223 if ((flags & SigmaValue) == 0)
6224 geometry_info.sigma=1.0;
6227 if (LocaleCompare(keyword,"gray") == 0)
6229 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6232 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6234 gray=(MagickBooleanType) option;
6237 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6243 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6249 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6250 geometry_info.sigma,msl_info->exception);
6251 if (shade_image == (Image *) NULL)
6253 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6254 msl_info->image[n]=shade_image;
6257 if (LocaleCompare((const char *) tag,"shadow") == 0)
6265 if (msl_info->image[n] == (Image *) NULL)
6267 ThrowMSLException(OptionError,"NoImagesDefined",
6268 (const char *) tag);
6271 if (attributes != (const xmlChar **) NULL)
6272 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6274 keyword=(const char *) attributes[i++];
6275 attribute=InterpretImageProperties(msl_info->image_info[n],
6276 msl_info->attributes[n],(const char *) attributes[i],
6278 CloneString(&value,attribute);
6284 if (LocaleCompare(keyword,"geometry") == 0)
6286 flags=ParseGeometry(value,&geometry_info);
6287 if ((flags & SigmaValue) == 0)
6288 geometry_info.sigma=1.0;
6291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6298 if (LocaleCompare(keyword,"opacity") == 0)
6300 geometry_info.rho=StringToLong(value);
6303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6310 if (LocaleCompare(keyword,"sigma") == 0)
6312 geometry_info.sigma=StringToLong(value);
6320 if (LocaleCompare(keyword,"x") == 0)
6322 geometry_info.xi=StringToDouble(value,
6326 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6333 if (LocaleCompare(keyword,"y") == 0)
6335 geometry_info.psi=StringToLong(value);
6338 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6344 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6350 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6351 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),
6352 (ssize_t) ceil(geometry_info.psi-0.5),msl_info->exception);
6353 if (shadow_image == (Image *) NULL)
6355 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6356 msl_info->image[n]=shadow_image;
6359 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6365 if (msl_info->image[n] == (Image *) NULL)
6367 ThrowMSLException(OptionError,"NoImagesDefined",
6368 (const char *) tag);
6372 NOTE: sharpen can have no attributes, since we use all the defaults!
6374 if (attributes != (const xmlChar **) NULL)
6376 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6378 keyword=(const char *) attributes[i++];
6379 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6380 msl_info->attributes[n],(const char *) attributes[i],exception));
6386 if (LocaleCompare(keyword, "radius") == 0)
6388 radius = StringToDouble(value,(char **) NULL);
6391 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6397 if (LocaleCompare(keyword,"sigma") == 0)
6399 sigma = StringToLong( value );
6402 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6407 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6421 newImage=SharpenImage(msl_info->image[n],radius,sigma,
6422 msl_info->exception);
6423 if (newImage == (Image *) NULL)
6425 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6426 msl_info->image[n]=newImage;
6430 else if (LocaleCompare((const char *) tag,"shave") == 0)
6432 /* init the values */
6436 if (msl_info->image[n] == (Image *) NULL)
6438 ThrowMSLException(OptionError,"NoImagesDefined",
6439 (const char *) tag);
6442 if (attributes == (const xmlChar **) NULL)
6444 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6446 keyword=(const char *) attributes[i++];
6447 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6448 msl_info->attributes[n],(const char *) attributes[i],exception));
6454 if (LocaleCompare(keyword,"geometry") == 0)
6456 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6459 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6465 if (LocaleCompare(keyword,"height") == 0)
6467 height = StringToLong( value );
6470 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6476 if (LocaleCompare(keyword,"width") == 0)
6478 width = StringToLong( value );
6481 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6486 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6501 rectInfo.height = height;
6502 rectInfo.width = width;
6507 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6508 msl_info->exception);
6509 if (newImage == (Image *) NULL)
6511 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6512 msl_info->image[n]=newImage;
6517 if (LocaleCompare((const char *) tag,"shear") == 0)
6525 if (msl_info->image[n] == (Image *) NULL)
6527 ThrowMSLException(OptionError,"NoImagesDefined",
6528 (const char *) tag);
6531 if (attributes != (const xmlChar **) NULL)
6532 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6534 keyword=(const char *) attributes[i++];
6535 attribute=InterpretImageProperties(msl_info->image_info[n],
6536 msl_info->attributes[n],(const char *) attributes[i],
6538 CloneString(&value,attribute);
6544 if (LocaleCompare(keyword, "fill") == 0)
6546 (void) QueryColorCompliance(value,AllCompliance,
6547 &msl_info->image[n]->background_color,exception);
6550 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6557 if (LocaleCompare(keyword,"geometry") == 0)
6559 flags=ParseGeometry(value,&geometry_info);
6560 if ((flags & SigmaValue) == 0)
6561 geometry_info.sigma=1.0;
6564 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6571 if (LocaleCompare(keyword,"x") == 0)
6573 geometry_info.rho=StringToDouble(value,
6577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6584 if (LocaleCompare(keyword,"y") == 0)
6586 geometry_info.sigma=StringToLong(value);
6589 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6601 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6602 geometry_info.sigma,msl_info->exception);
6603 if (shear_image == (Image *) NULL)
6605 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6606 msl_info->image[n]=shear_image;
6609 if (LocaleCompare((const char *) tag,"signature") == 0)
6614 if (msl_info->image[n] == (Image *) NULL)
6616 ThrowMSLException(OptionError,"NoImagesDefined",
6617 (const char *) tag);
6620 if (attributes != (const xmlChar **) NULL)
6621 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6623 keyword=(const char *) attributes[i++];
6624 attribute=InterpretImageProperties(msl_info->image_info[n],
6625 msl_info->attributes[n],(const char *) attributes[i],
6627 CloneString(&value,attribute);
6632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6638 (void) SignatureImage(msl_info->image[n],exception);
6641 if (LocaleCompare((const char *) tag,"solarize") == 0)
6646 if (msl_info->image[n] == (Image *) NULL)
6648 ThrowMSLException(OptionError,"NoImagesDefined",
6649 (const char *) tag);
6652 geometry_info.rho=QuantumRange/2.0;
6653 if (attributes != (const xmlChar **) NULL)
6654 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6656 keyword=(const char *) attributes[i++];
6657 attribute=InterpretImageProperties(msl_info->image_info[n],
6658 msl_info->attributes[n],(const char *) attributes[i],
6660 CloneString(&value,attribute);
6666 if (LocaleCompare(keyword,"geometry") == 0)
6668 flags=ParseGeometry(value,&geometry_info);
6671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6678 if (LocaleCompare(keyword,"threshold") == 0)
6680 geometry_info.rho=StringToDouble(value,
6684 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6690 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6696 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6697 msl_info->exception);
6700 if (LocaleCompare((const char *) tag,"spread") == 0)
6708 if (msl_info->image[n] == (Image *) NULL)
6710 ThrowMSLException(OptionError,"NoImagesDefined",
6711 (const char *) tag);
6714 if (attributes != (const xmlChar **) NULL)
6715 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6717 keyword=(const char *) attributes[i++];
6718 attribute=InterpretImageProperties(msl_info->image_info[n],
6719 msl_info->attributes[n],(const char *) attributes[i],
6721 CloneString(&value,attribute);
6727 if (LocaleCompare(keyword,"geometry") == 0)
6729 flags=ParseGeometry(value,&geometry_info);
6730 if ((flags & SigmaValue) == 0)
6731 geometry_info.sigma=1.0;
6734 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6741 if (LocaleCompare(keyword,"radius") == 0)
6743 geometry_info.rho=StringToDouble(value,
6747 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6753 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6759 spread_image=SpreadImage(msl_info->image[n],
6760 msl_info->image[n]->interpolate,geometry_info.rho,
6761 msl_info->exception);
6762 if (spread_image == (Image *) NULL)
6764 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6765 msl_info->image[n]=spread_image;
6768 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6771 watermark = (Image*) NULL;
6773 if (msl_info->image[n] == (Image *) NULL)
6775 ThrowMSLException(OptionError,"NoImagesDefined",
6776 (const char *) tag);
6779 if (attributes == (const xmlChar **) NULL)
6781 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6783 keyword=(const char *) attributes[i++];
6784 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6785 msl_info->attributes[n],(const char *) attributes[i],exception));
6791 if (LocaleCompare(keyword,"image") == 0)
6793 for (j=0; j<msl_info->n;j++)
6796 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6798 if (theAttr && LocaleCompare(theAttr, value) == 0)
6800 watermark = msl_info->image[j];
6806 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6811 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6820 if ( watermark != (Image*) NULL )
6825 newImage=SteganoImage(msl_info->image[n], watermark, msl_info->exception);
6826 if (newImage == (Image *) NULL)
6828 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6829 msl_info->image[n]=newImage;
6832 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6834 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6837 stereoImage = (Image*) NULL;
6839 if (msl_info->image[n] == (Image *) NULL)
6841 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6844 if (attributes == (const xmlChar **) NULL)
6846 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6848 keyword=(const char *) attributes[i++];
6849 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6850 msl_info->attributes[n],(const char *) attributes[i],exception));
6856 if (LocaleCompare(keyword,"image") == 0)
6858 for (j=0; j<msl_info->n;j++)
6861 theAttr = GetImageProperty(msl_info->attributes[j], "id",
6863 if (theAttr && LocaleCompare(theAttr, value) == 0)
6865 stereoImage = msl_info->image[j];
6871 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6876 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6885 if ( stereoImage != (Image*) NULL )
6890 newImage=StereoImage(msl_info->image[n], stereoImage, msl_info->exception);
6891 if (newImage == (Image *) NULL)
6893 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6894 msl_info->image[n]=newImage;
6897 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6899 if (LocaleCompare((const char *) tag,"strip") == 0)
6904 if (msl_info->image[n] == (Image *) NULL)
6906 ThrowMSLException(OptionError,"NoImagesDefined",
6907 (const char *) tag);
6910 if (attributes != (const xmlChar **) NULL)
6911 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6913 keyword=(const char *) attributes[i++];
6914 attribute=InterpretImageProperties(msl_info->image_info[n],
6915 msl_info->attributes[n],(const char *) attributes[i],
6917 CloneString(&value,attribute);
6918 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6920 (void) StripImage(msl_info->image[n],msl_info->exception);
6923 if (LocaleCompare((const char *) tag,"swap") == 0)
6934 if (msl_info->image[n] == (Image *) NULL)
6936 ThrowMSLException(OptionError,"NoImagesDefined",
6937 (const char *) tag);
6942 if (attributes != (const xmlChar **) NULL)
6943 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6945 keyword=(const char *) attributes[i++];
6946 attribute=InterpretImageProperties(msl_info->image_info[n],
6947 msl_info->attributes[n],(const char *) attributes[i],
6949 CloneString(&value,attribute);
6955 if (LocaleCompare(keyword,"indexes") == 0)
6957 flags=ParseGeometry(value,&geometry_info);
6958 index=(ssize_t) geometry_info.rho;
6959 if ((flags & SigmaValue) == 0)
6960 swap_index=(ssize_t) geometry_info.sigma;
6963 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6969 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6978 p=GetImageFromList(msl_info->image[n],index);
6979 q=GetImageFromList(msl_info->image[n],swap_index);
6980 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6982 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6985 swap=CloneImage(p,0,0,MagickTrue,msl_info->exception);
6986 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,
6987 msl_info->exception));
6988 ReplaceImageInList(&q,swap);
6989 msl_info->image[n]=GetFirstImageInList(q);
6992 if (LocaleCompare((const char *) tag,"swirl") == 0)
7000 if (msl_info->image[n] == (Image *) NULL)
7002 ThrowMSLException(OptionError,"NoImagesDefined",
7003 (const char *) tag);
7006 if (attributes != (const xmlChar **) NULL)
7007 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7009 keyword=(const char *) attributes[i++];
7010 attribute=InterpretImageProperties(msl_info->image_info[n],
7011 msl_info->attributes[n],(const char *) attributes[i],
7013 CloneString(&value,attribute);
7019 if (LocaleCompare(keyword,"degrees") == 0)
7021 geometry_info.rho=StringToDouble(value,
7025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7032 if (LocaleCompare(keyword,"geometry") == 0)
7034 flags=ParseGeometry(value,&geometry_info);
7035 if ((flags & SigmaValue) == 0)
7036 geometry_info.sigma=1.0;
7039 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7051 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7052 msl_info->image[n]->interpolate,msl_info->exception);
7053 if (swirl_image == (Image *) NULL)
7055 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7056 msl_info->image[n]=swirl_image;
7059 if (LocaleCompare((const char *) tag,"sync") == 0)
7064 if (msl_info->image[n] == (Image *) NULL)
7066 ThrowMSLException(OptionError,"NoImagesDefined",
7067 (const char *) tag);
7070 if (attributes != (const xmlChar **) NULL)
7071 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7073 keyword=(const char *) attributes[i++];
7074 attribute=InterpretImageProperties(msl_info->image_info[n],
7075 msl_info->attributes[n],(const char *) attributes[i],
7077 CloneString(&value,attribute);
7082 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7088 (void) SyncImage(msl_info->image[n],exception);
7091 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7096 if (LocaleCompare((const char *) tag,"map") == 0)
7104 if (msl_info->image[n] == (Image *) NULL)
7106 ThrowMSLException(OptionError,"NoImagesDefined",
7107 (const char *) tag);
7110 texture_image=NewImageList();
7111 if (attributes != (const xmlChar **) NULL)
7112 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7114 keyword=(const char *) attributes[i++];
7115 attribute=InterpretImageProperties(msl_info->image_info[n],
7116 msl_info->attributes[n],(const char *) attributes[i],
7118 CloneString(&value,attribute);
7124 if (LocaleCompare(keyword,"image") == 0)
7125 for (j=0; j < msl_info->n; j++)
7130 attribute=GetImageProperty(msl_info->attributes[j],"id",
7132 if ((attribute != (const char *) NULL) &&
7133 (LocaleCompare(attribute,value) == 0))
7135 texture_image=CloneImage(msl_info->image[j],0,0,
7136 MagickFalse,exception);
7144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7150 (void) TextureImage(msl_info->image[n],texture_image,exception);
7151 texture_image=DestroyImage(texture_image);
7154 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7156 /* init the values */
7157 double threshold = 0;
7159 if (msl_info->image[n] == (Image *) NULL)
7161 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7164 if (attributes == (const xmlChar **) NULL)
7166 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7168 keyword=(const char *) attributes[i++];
7169 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7170 msl_info->attributes[n],(const char *) attributes[i],exception));
7176 if (LocaleCompare(keyword,"threshold") == 0)
7178 threshold = StringToDouble(value,(char **) NULL);
7181 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7186 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7196 BilevelImage(msl_info->image[n],threshold,exception);
7200 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7202 if (msl_info->image[n] == (Image *) NULL)
7204 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7207 if (attributes == (const xmlChar **) NULL)
7209 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7211 keyword=(const char *) attributes[i++];
7212 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7213 msl_info->attributes[n],(const char *) attributes[i],exception));
7219 if (LocaleCompare(keyword,"color") == 0)
7224 (void) QueryColorCompliance(value,AllCompliance,&target,
7226 (void) TransparentPaintImage(msl_info->image[n],&target,
7227 TransparentAlpha,MagickFalse,msl_info->exception);
7230 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7235 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7242 else if (LocaleCompare((const char *) tag, "trim") == 0)
7244 if (msl_info->image[n] == (Image *) NULL)
7246 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7250 /* no attributes here */
7252 /* process the image */
7259 /* all zeros on a crop == trim edges! */
7260 rectInfo.height = rectInfo.width = 0;
7261 rectInfo.x = rectInfo.y = 0;
7263 newImage=CropImage(msl_info->image[n],&rectInfo, msl_info->exception);
7264 if (newImage == (Image *) NULL)
7266 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7267 msl_info->image[n]=newImage;
7271 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7276 if (LocaleCompare((const char *) tag,"write") == 0)
7278 if (msl_info->image[n] == (Image *) NULL)
7280 ThrowMSLException(OptionError,"NoImagesDefined",
7281 (const char *) tag);
7284 if (attributes == (const xmlChar **) NULL)
7286 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7288 keyword=(const char *) attributes[i++];
7289 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7290 msl_info->attributes[n],(const char *) attributes[i],exception));
7296 if (LocaleCompare(keyword,"filename") == 0)
7298 (void) CopyMagickString(msl_info->image[n]->filename,value,
7302 (void) SetMSLAttributes(msl_info,keyword,value);
7306 (void) SetMSLAttributes(msl_info,keyword,value);
7314 *msl_info->image_info[n]->magick='\0';
7315 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7316 msl_info->exception);
7320 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7324 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7328 if ( value != NULL )
7329 value=DestroyString(value);
7330 (void) DestroyExceptionInfo(exception);
7331 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7334 static void MSLEndElement(void *context,const xmlChar *tag)
7343 Called when the end of an element has been detected.
7345 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7347 msl_info=(MSLInfo *) context;
7354 if (LocaleCompare((const char *) tag,"comment") == 0 )
7356 (void) DeleteImageProperty(msl_info->image[n],"comment");
7357 if (msl_info->content == (char *) NULL)
7359 StripString(msl_info->content);
7360 (void) SetImageProperty(msl_info->image[n],"comment",
7361 msl_info->content,msl_info->exception);
7369 if (LocaleCompare((const char *) tag, "group") == 0 )
7371 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7373 ssize_t i = (ssize_t)
7374 (msl_info->group_info[msl_info->number_groups-1].numImages);
7377 if (msl_info->image[msl_info->n] != (Image *) NULL)
7378 msl_info->image[msl_info->n]=DestroyImage(
7379 msl_info->image[msl_info->n]);
7380 msl_info->attributes[msl_info->n]=DestroyImage(
7381 msl_info->attributes[msl_info->n]);
7382 msl_info->image_info[msl_info->n]=DestroyImageInfo(
7383 msl_info->image_info[msl_info->n]);
7387 msl_info->number_groups--;
7394 if (LocaleCompare((const char *) tag, "image") == 0)
7395 MSLPopImage(msl_info);
7401 if (LocaleCompare((const char *) tag,"label") == 0 )
7403 (void) DeleteImageProperty(msl_info->image[n],"label");
7404 if (msl_info->content == (char *) NULL)
7406 StripString(msl_info->content);
7407 (void) SetImageProperty(msl_info->image[n],"label",
7408 msl_info->content,msl_info->exception);
7416 if (LocaleCompare((const char *) tag, "msl") == 0 )
7419 This our base element.
7420 at the moment we don't do anything special
7421 but someday we might!
7429 if (msl_info->content != (char *) NULL)
7430 msl_info->content=DestroyString(msl_info->content);
7433 static void MSLCharacters(void *context,const xmlChar *c,int length)
7445 Receiving some characters from the parser.
7447 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7448 " SAX.characters(%s,%d)",c,length);
7449 msl_info=(MSLInfo *) context;
7450 if (msl_info->content != (char *) NULL)
7451 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7452 strlen(msl_info->content)+length+MagickPathExtent,
7453 sizeof(*msl_info->content));
7456 msl_info->content=(char *) NULL;
7457 if (~length >= (MagickPathExtent-1))
7458 msl_info->content=(char *) AcquireQuantumMemory(length+MagickPathExtent,
7459 sizeof(*msl_info->content));
7460 if (msl_info->content != (char *) NULL)
7461 *msl_info->content='\0';
7463 if (msl_info->content == (char *) NULL)
7465 p=msl_info->content+strlen(msl_info->content);
7466 for (i=0; i < length; i++)
7471 static void MSLReference(void *context,const xmlChar *name)
7480 Called when an entity reference is detected.
7482 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7483 " SAX.reference(%s)",name);
7484 msl_info=(MSLInfo *) context;
7485 parser=msl_info->parser;
7487 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7489 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7492 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7498 Receiving some ignorable whitespaces from the parser.
7500 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7501 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7502 msl_info=(MSLInfo *) context;
7506 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7507 const xmlChar *data)
7513 A processing instruction has been parsed.
7515 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7516 " SAX.processingInstruction(%s, %s)",
7518 msl_info=(MSLInfo *) context;
7522 static void MSLComment(void *context,const xmlChar *value)
7528 A comment has been parsed.
7530 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7531 " SAX.comment(%s)",value);
7532 msl_info=(MSLInfo *) context;
7536 static void MSLWarning(void *context,const char *format,...)
7540 reason[MagickPathExtent];
7549 Display and format a warning messages, gives file, line, position and
7552 va_start(operands,format);
7553 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7554 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7555 msl_info=(MSLInfo *) context;
7557 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7558 (void) vsprintf(reason,format,operands);
7560 (void) vsnprintf(reason,MagickPathExtent,format,operands);
7562 message=GetExceptionMessage(errno);
7563 ThrowMSLException(CoderError,reason,message);
7564 message=DestroyString(message);
7568 static void MSLError(void *context,const char *format,...)
7571 reason[MagickPathExtent];
7580 Display and format a error formats, gives file, line, position and
7583 va_start(operands,format);
7584 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7585 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7586 msl_info=(MSLInfo *) context;
7588 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7589 (void) vsprintf(reason,format,operands);
7591 (void) vsnprintf(reason,MagickPathExtent,format,operands);
7593 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7597 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7609 Called when a pcdata block has been parsed.
7611 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7612 " SAX.pcdata(%s, %d)",value,length);
7613 msl_info=(MSLInfo *) context;
7615 parser=msl_info->parser;
7616 child=xmlGetLastChild(parser->node);
7617 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7619 xmlTextConcat(child,value,length);
7622 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7625 static void MSLExternalSubset(void *context,const xmlChar *name,
7626 const xmlChar *external_id,const xmlChar *system_id)
7641 Does this document has an external subset?
7643 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7644 " SAX.externalSubset(%s %s %s)",name,
7645 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7646 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7647 msl_info=(MSLInfo *) context;
7649 parser=msl_info->parser;
7650 if (((external_id == NULL) && (system_id == NULL)) ||
7651 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7652 (msl_info->document == 0)))
7654 input=MSLResolveEntity(context,external_id,system_id);
7657 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7658 parser_context=(*parser);
7659 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7660 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7662 parser->errNo=XML_ERR_NO_MEMORY;
7663 parser->input=parser_context.input;
7664 parser->inputNr=parser_context.inputNr;
7665 parser->inputMax=parser_context.inputMax;
7666 parser->inputTab=parser_context.inputTab;
7672 xmlPushInput(parser,input);
7673 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7674 if (input->filename == (char *) NULL)
7675 input->filename=(char *) xmlStrdup(system_id);
7678 input->base=parser->input->cur;
7679 input->cur=parser->input->cur;
7681 xmlParseExternalSubset(parser,external_id,system_id);
7682 while (parser->inputNr > 1)
7683 (void) xmlPopInput(parser);
7684 xmlFreeInputStream(parser->input);
7685 xmlFree(parser->inputTab);
7686 parser->input=parser_context.input;
7687 parser->inputNr=parser_context.inputNr;
7688 parser->inputMax=parser_context.inputMax;
7689 parser->inputTab=parser_context.inputTab;
7692 #if defined(__cplusplus) || defined(c_plusplus)
7696 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,
7697 Image **image,ExceptionInfo *exception)
7700 message[MagickPathExtent];
7723 assert(image_info != (const ImageInfo *) NULL);
7724 assert(image_info->signature == MagickCoreSignature);
7725 if (image_info->debug != MagickFalse)
7726 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7727 image_info->filename);
7728 assert(image != (Image **) NULL);
7729 msl_image=AcquireImage(image_info,exception);
7730 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7731 if (status == MagickFalse)
7733 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7734 msl_image->filename);
7735 msl_image=DestroyImageList(msl_image);
7736 return(MagickFalse);
7738 msl_image->columns=1;
7743 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7744 msl_info.exception=exception;
7745 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7746 sizeof(*msl_info.image_info));
7747 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7748 sizeof(*msl_info.draw_info));
7749 /* top of the stack is the MSL file itself */
7750 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7751 msl_info.attributes=(Image **) AcquireMagickMemory(
7752 sizeof(*msl_info.attributes));
7753 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7754 sizeof(*msl_info.group_info));
7755 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7756 (msl_info.image == (Image **) NULL) ||
7757 (msl_info.attributes == (Image **) NULL) ||
7758 (msl_info.group_info == (MSLGroupInfo *) NULL))
7759 ThrowFatalException(ResourceLimitFatalError,
7760 "UnableToInterpretMSLImage");
7761 *msl_info.image_info=CloneImageInfo(image_info);
7762 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7763 *msl_info.attributes=AcquireImage(image_info,exception);
7764 msl_info.group_info[0].numImages=0;
7765 /* the first slot is used to point to the MSL file image */
7766 *msl_info.image=msl_image;
7767 if (*image != (Image *) NULL)
7768 MSLPushImage(&msl_info,*image);
7769 (void) xmlSubstituteEntitiesDefault(1);
7770 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7771 sax_modules.internalSubset=MSLInternalSubset;
7772 sax_modules.isStandalone=MSLIsStandalone;
7773 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7774 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7775 sax_modules.resolveEntity=MSLResolveEntity;
7776 sax_modules.getEntity=MSLGetEntity;
7777 sax_modules.entityDecl=MSLEntityDeclaration;
7778 sax_modules.notationDecl=MSLNotationDeclaration;
7779 sax_modules.attributeDecl=MSLAttributeDeclaration;
7780 sax_modules.elementDecl=MSLElementDeclaration;
7781 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7782 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7783 sax_modules.startDocument=MSLStartDocument;
7784 sax_modules.endDocument=MSLEndDocument;
7785 sax_modules.startElement=MSLStartElement;
7786 sax_modules.endElement=MSLEndElement;
7787 sax_modules.reference=MSLReference;
7788 sax_modules.characters=MSLCharacters;
7789 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7790 sax_modules.processingInstruction=MSLProcessingInstructions;
7791 sax_modules.comment=MSLComment;
7792 sax_modules.warning=MSLWarning;
7793 sax_modules.error=MSLError;
7794 sax_modules.fatalError=MSLError;
7795 sax_modules.getParameterEntity=MSLGetParameterEntity;
7796 sax_modules.cdataBlock=MSLCDataBlock;
7797 sax_modules.externalSubset=MSLExternalSubset;
7798 sax_handler=(&sax_modules);
7799 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7800 msl_image->filename);
7801 while (ReadBlobString(msl_image,message) != (char *) NULL)
7803 n=(ssize_t) strlen(message);
7806 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7809 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7810 if (msl_info.exception->severity >= ErrorException)
7813 if (msl_info.exception->severity == UndefinedException)
7814 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7815 xmlFreeParserCtxt(msl_info.parser);
7816 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7817 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7818 msl_info.group_info);
7819 if (*image == (Image *) NULL)
7820 *image=(*msl_info.image);
7821 if (msl_info.exception->severity != UndefinedException)
7822 return(MagickFalse);
7826 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7834 assert(image_info != (const ImageInfo *) NULL);
7835 assert(image_info->signature == MagickCoreSignature);
7836 if (image_info->debug != MagickFalse)
7837 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7838 image_info->filename);
7839 assert(exception != (ExceptionInfo *) NULL);
7840 assert(exception->signature == MagickCoreSignature);
7841 image=(Image *) NULL;
7842 (void) ProcessMSLScript(image_info,&image,exception);
7843 return(GetFirstImageInList(image));
7848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7852 % R e g i s t e r M S L I m a g e %
7856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7858 % RegisterMSLImage() adds attributes for the MSL image format to
7859 % the list of supported formats. The attributes include the image format
7860 % tag, a method to read and/or write the format, whether the format
7861 % supports the saving of more than one frame to the same file or blob,
7862 % whether the format supports native in-memory I/O, and a brief
7863 % description of the format.
7865 % The format of the RegisterMSLImage method is:
7867 % size_t RegisterMSLImage(void)
7870 ModuleExport size_t RegisterMSLImage(void)
7875 #if defined(MAGICKCORE_XML_DELEGATE)
7878 entry=AcquireMagickInfo("MSL","MSL","Magick Scripting Language");
7879 #if defined(MAGICKCORE_XML_DELEGATE)
7880 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7881 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7883 entry->format_type=ImplicitFormatType;
7884 (void) RegisterMagickInfo(entry);
7885 return(MagickImageCoderSignature);
7888 #if defined(MAGICKCORE_XML_DELEGATE)
7890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7894 % S e t M S L A t t r i b u t e s %
7898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7900 % SetMSLAttributes() ...
7902 % The format of the SetMSLAttributes method is:
7904 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7905 % const char *keyword,const char *value)
7907 % A description of each parameter follows:
7909 % o msl_info: the MSL info.
7911 % o keyword: the keyword.
7913 % o value: the value.
7916 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7943 assert(msl_info != (MSLInfo *) NULL);
7944 if (keyword == (const char *) NULL)
7946 if (value == (const char *) NULL)
7948 exception=msl_info->exception;
7950 attributes=msl_info->attributes[n];
7951 image_info=msl_info->image_info[n];
7952 draw_info=msl_info->draw_info[n];
7953 image=msl_info->image[n];
7959 if (LocaleCompare(keyword,"adjoin") == 0)
7964 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7966 ThrowMSLException(OptionError,"UnrecognizedType",value);
7967 image_info->adjoin=(MagickBooleanType) adjoin;
7970 if (LocaleCompare(keyword,"alpha") == 0)
7975 alpha=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,value);
7977 ThrowMSLException(OptionError,"UnrecognizedType",value);
7978 if (image != (Image *) NULL)
7979 (void) SetImageAlphaChannel(image,(AlphaChannelOption) alpha,
7983 if (LocaleCompare(keyword,"alpha-color") == 0)
7985 (void) QueryColorCompliance(value,AllCompliance,
7986 &image_info->alpha_color,exception);
7989 if (LocaleCompare(keyword,"antialias") == 0)
7994 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7996 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7997 image_info->antialias=(MagickBooleanType) antialias;
8000 if (LocaleCompare(keyword,"area-limit") == 0)
8005 limit=MagickResourceInfinity;
8006 if (LocaleCompare(value,"unlimited") != 0)
8007 limit=(MagickSizeType) StringToDoubleInterval(value,100.0);
8008 (void) SetMagickResourceLimit(AreaResource,limit);
8011 if (LocaleCompare(keyword,"attenuate") == 0)
8013 (void) SetImageOption(image_info,keyword,value);
8016 if (LocaleCompare(keyword,"authenticate") == 0)
8018 (void) CloneString(&image_info->density,value);
8021 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8027 if (LocaleCompare(keyword,"background") == 0)
8029 (void) QueryColorCompliance(value,AllCompliance,
8030 &image_info->background_color,exception);
8033 if (LocaleCompare(keyword,"blue-primary") == 0)
8035 if (image == (Image *) NULL)
8037 flags=ParseGeometry(value,&geometry_info);
8038 image->chromaticity.blue_primary.x=geometry_info.rho;
8039 image->chromaticity.blue_primary.y=geometry_info.sigma;
8040 if ((flags & SigmaValue) == 0)
8041 image->chromaticity.blue_primary.y=
8042 image->chromaticity.blue_primary.x;
8045 if (LocaleCompare(keyword,"bordercolor") == 0)
8047 (void) QueryColorCompliance(value,AllCompliance,
8048 &image_info->border_color,exception);
8051 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8057 if (LocaleCompare(keyword,"density") == 0)
8059 (void) CloneString(&image_info->density,value);
8060 (void) CloneString(&draw_info->density,value);
8063 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8069 if (LocaleCompare(keyword,"fill") == 0)
8071 (void) QueryColorCompliance(value,AllCompliance,&draw_info->fill,
8073 (void) SetImageOption(image_info,keyword,value);
8076 if (LocaleCompare(keyword,"filename") == 0)
8078 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
8081 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8087 if (LocaleCompare(keyword,"gravity") == 0)
8092 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8094 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8095 (void) SetImageOption(image_info,keyword,value);
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"id") == 0)
8106 (void) SetImageProperty(attributes,keyword,value,exception);
8109 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8115 if (LocaleCompare(keyword,"magick") == 0)
8117 (void) CopyMagickString(image_info->magick,value,MagickPathExtent);
8120 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8126 if (LocaleCompare(keyword,"pointsize") == 0)
8128 image_info->pointsize=StringToDouble(value,(char **) NULL);
8129 draw_info->pointsize=StringToDouble(value,(char **) NULL);
8132 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8138 if (LocaleCompare(keyword,"quality") == 0)
8140 image_info->quality=StringToLong(value);
8141 if (image == (Image *) NULL)
8143 image->quality=StringToLong(value);
8151 if (LocaleCompare(keyword,"size") == 0)
8153 (void) CloneString(&image_info->size,value);
8156 if (LocaleCompare(keyword,"stroke") == 0)
8158 (void) QueryColorCompliance(value,AllCompliance,&draw_info->stroke,
8160 (void) SetImageOption(image_info,keyword,value);
8163 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8168 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8181 % U n r e g i s t e r M S L I m a g e %
8185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8187 % UnregisterMSLImage() removes format registrations made by the
8188 % MSL module from the list of supported formats.
8190 % The format of the UnregisterMSLImage method is:
8192 % UnregisterMSLImage(void)
8195 ModuleExport void UnregisterMSLImage(void)
8197 (void) UnregisterMagickInfo("MSL");
8198 #if defined(MAGICKCORE_XML_DELEGATE)
8203 #if defined(MAGICKCORE_XML_DELEGATE)
8205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8209 % W r i t e M S L I m a g e %
8213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8215 % WriteMSLImage() writes an image to a file in MVG image format.
8217 % The format of the WriteMSLImage method is:
8219 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8220 % Image *image,ExceptionInfo *exception)
8222 % A description of each parameter follows.
8224 % o image_info: the image info.
8226 % o image: The image.
8228 % o exception: return any errors or warnings in this structure.
8231 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8232 ExceptionInfo *exception)
8234 assert(image_info != (const ImageInfo *) NULL);
8235 assert(image_info->signature == MagickCoreSignature);
8236 assert(image != (Image *) NULL);
8237 assert(image->signature == MagickCoreSignature);
8238 if (image->debug != MagickFalse)
8239 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8240 (void) ReferenceImage(image);
8241 (void) ProcessMSLScript(image_info,&image,exception);