2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Execute Magick Scripting Language Scripts. %
22 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
23 % dedicated to making software imaging solutions freely available. %
25 % You may not use this file except in compliance with the License. You may %
26 % obtain a copy of the License at %
28 % http://www.imagemagick.org/script/license.php %
30 % Unless required by applicable law or agreed to in writing, software %
31 % distributed under the License is distributed on an "AS IS" BASIS, %
32 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
33 % See the License for the specific language governing permissions and %
34 % limitations under the License. %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 #include "MagickCore/studio.h"
45 #include "MagickCore/annotate.h"
46 #include "MagickCore/artifact.h"
47 #include "MagickCore/blob.h"
48 #include "MagickCore/blob-private.h"
49 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/color.h"
52 #include "MagickCore/colormap.h"
53 #include "MagickCore/color-private.h"
54 #include "MagickCore/composite.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/decorate.h"
57 #include "MagickCore/display.h"
58 #include "MagickCore/draw.h"
59 #include "MagickCore/effect.h"
60 #include "MagickCore/enhance.h"
61 #include "MagickCore/exception.h"
62 #include "MagickCore/exception-private.h"
63 #include "MagickCore/fx.h"
64 #include "MagickCore/geometry.h"
65 #include "MagickCore/image.h"
66 #include "MagickCore/image-private.h"
67 #include "MagickCore/list.h"
68 #include "MagickCore/log.h"
69 #include "MagickCore/magick.h"
70 #include "MagickCore/memory_.h"
71 #include "MagickCore/module.h"
72 #include "MagickCore/option.h"
73 #include "MagickCore/paint.h"
74 #include "MagickCore/pixel-accessor.h"
75 #include "MagickCore/profile.h"
76 #include "MagickCore/property.h"
77 #include "MagickCore/quantize.h"
78 #include "MagickCore/quantum-private.h"
79 #include "MagickCore/registry.h"
80 #include "MagickCore/resize.h"
81 #include "MagickCore/resource_.h"
82 #include "MagickCore/segment.h"
83 #include "MagickCore/shear.h"
84 #include "MagickCore/signature.h"
85 #include "MagickCore/static.h"
86 #include "MagickCore/string_.h"
87 #include "MagickCore/string-private.h"
88 #include "MagickCore/transform.h"
89 #include "MagickCore/threshold.h"
90 #include "MagickCore/utility.h"
91 #if defined(MAGICKCORE_XML_DELEGATE)
92 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
93 # if defined(__MINGW32__)
96 # include <win32config.h>
99 # include <libxml/parser.h>
100 # include <libxml/xmlmemory.h>
101 # include <libxml/parserInternals.h>
102 # include <libxml/xmlerror.h>
108 #define ThrowMSLException(severity,tag,reason) \
109 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
113 Typedef declaractions.
115 typedef struct _MSLGroupInfo
118 numImages; /* how many images are in this group */
121 typedef struct _MSLInfo
146 #if defined(MAGICKCORE_XML_DELEGATE)
156 Forward declarations.
158 #if defined(MAGICKCORE_XML_DELEGATE)
159 static MagickBooleanType
160 WriteMSLImage(const ImageInfo *,Image *,ExceptionInfo *);
162 static MagickBooleanType
163 SetMSLAttributes(MSLInfo *,const char *,const char *);
166 #if defined(MAGICKCORE_XML_DELEGATE)
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 % R e a d M S L I m a g e %
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
180 % It allocates the memory necessary for the new Image structure and returns a
181 % pointer to the new image.
183 % The format of the ReadMSLImage method is:
185 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
187 % A description of each parameter follows:
189 % o image_info: the image info.
191 % o exception: return any errors or warnings in this structure.
195 #if defined(__cplusplus) || defined(c_plusplus)
199 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
200 ExceptionInfo *exception)
214 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
215 sans_exception=AcquireExceptionInfo();
216 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
217 sans_exception=DestroyExceptionInfo(sans_exception);
218 if (image != (Image *) NULL)
220 read_info=CloneImageInfo(image_info);
221 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
222 image=ReadImage(read_info,exception);
223 read_info=DestroyImageInfo(read_info);
224 if (image != (Image *) NULL)
225 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
229 static int IsPathDirectory(const char *path)
237 if ((path == (const char *) NULL) || (*path == '\0'))
239 status=GetPathAttributes(path,&attributes);
240 if (status == MagickFalse)
242 if (S_ISDIR(attributes.st_mode) == 0)
247 static int MSLIsStandalone(void *context)
253 Is this document tagged standalone?
255 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
256 msl_info=(MSLInfo *) context;
257 return(msl_info->document->standalone == 1);
260 static int MSLHasInternalSubset(void *context)
266 Does this document has an internal subset?
268 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
269 " SAX.MSLHasInternalSubset()");
270 msl_info=(MSLInfo *) context;
271 return(msl_info->document->intSubset != NULL);
274 static int MSLHasExternalSubset(void *context)
280 Does this document has an external subset?
282 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
283 " SAX.MSLHasExternalSubset()");
284 msl_info=(MSLInfo *) context;
285 return(msl_info->document->extSubset != NULL);
288 static void MSLInternalSubset(void *context,const xmlChar *name,
289 const xmlChar *external_id,const xmlChar *system_id)
295 Does this document has an internal subset?
297 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
298 " SAX.internalSubset(%s %s %s)",name,
299 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
300 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
301 msl_info=(MSLInfo *) context;
302 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
305 static xmlParserInputPtr MSLResolveEntity(void *context,
306 const xmlChar *public_id,const xmlChar *system_id)
315 Special entity resolver, better left to the parser, it has more
316 context than the application layer. The default behaviour is to
317 not resolve the entities, in that case the ENTITY_REF nodes are
318 built in the structure (and the parameter values).
320 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
321 " SAX.resolveEntity(%s, %s)",
322 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
323 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
324 msl_info=(MSLInfo *) context;
325 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
326 public_id,msl_info->parser);
330 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
336 Get an entity by name.
338 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
339 " SAX.MSLGetEntity(%s)",(const char *) name);
340 msl_info=(MSLInfo *) context;
341 return(xmlGetDocEntity(msl_info->document,name));
344 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
350 Get a parameter entity by name.
352 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
353 " SAX.getParameterEntity(%s)",(const char *) name);
354 msl_info=(MSLInfo *) context;
355 return(xmlGetParameterEntity(msl_info->document,name));
358 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
359 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
365 An entity definition has been parsed.
367 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
368 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
369 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
370 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
372 msl_info=(MSLInfo *) context;
373 if (msl_info->parser->inSubset == 1)
374 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
377 if (msl_info->parser->inSubset == 2)
378 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
382 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
383 const xmlChar *name,int type,int value,const xmlChar *default_value,
384 xmlEnumerationPtr tree)
397 An attribute definition has been parsed.
399 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
400 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
402 msl_info=(MSLInfo *) context;
403 fullname=(xmlChar *) NULL;
404 prefix=(xmlChar *) NULL;
405 parser=msl_info->parser;
406 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
407 if (parser->inSubset == 1)
408 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
409 element,fullname,prefix,(xmlAttributeType) type,
410 (xmlAttributeDefault) value,default_value,tree);
412 if (parser->inSubset == 2)
413 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
414 element,fullname,prefix,(xmlAttributeType) type,
415 (xmlAttributeDefault) value,default_value,tree);
416 if (prefix != (xmlChar *) NULL)
418 if (fullname != (xmlChar *) NULL)
422 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
423 xmlElementContentPtr content)
432 An element definition has been parsed.
434 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
435 " SAX.elementDecl(%s, %d, ...)",name,type);
436 msl_info=(MSLInfo *) context;
437 parser=msl_info->parser;
438 if (parser->inSubset == 1)
439 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
440 name,(xmlElementTypeVal) type,content);
442 if (parser->inSubset == 2)
443 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
444 name,(xmlElementTypeVal) type,content);
447 static void MSLNotationDeclaration(void *context,const xmlChar *name,
448 const xmlChar *public_id,const xmlChar *system_id)
457 What to do when a notation declaration has been parsed.
459 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
460 " SAX.notationDecl(%s, %s, %s)",name,
461 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
462 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
463 msl_info=(MSLInfo *) context;
464 parser=msl_info->parser;
465 if (parser->inSubset == 1)
466 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
467 name,public_id,system_id);
469 if (parser->inSubset == 2)
470 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
471 name,public_id,system_id);
474 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
475 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
481 What to do when an unparsed entity declaration is parsed.
483 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
484 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
485 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
486 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
488 msl_info=(MSLInfo *) context;
489 (void) xmlAddDocEntity(msl_info->document,name,
490 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
494 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
500 Receive the document locator at startup, actually xmlDefaultSAXLocator.
502 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
503 " SAX.setDocumentLocator()\n");
505 msl_info=(MSLInfo *) context;
509 static void MSLStartDocument(void *context)
518 Called when the document start being processed.
520 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
521 " SAX.startDocument()");
522 msl_info=(MSLInfo *) context;
523 parser=msl_info->parser;
524 msl_info->document=xmlNewDoc(parser->version);
525 if (msl_info->document == (xmlDocPtr) NULL)
527 if (parser->encoding == NULL)
528 msl_info->document->encoding=NULL;
530 msl_info->document->encoding=xmlStrdup(parser->encoding);
531 msl_info->document->standalone=parser->standalone;
534 static void MSLEndDocument(void *context)
540 Called when the document end has been detected.
542 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
543 msl_info=(MSLInfo *) context;
544 if (msl_info->content != (char *) NULL)
545 msl_info->content=DestroyString(msl_info->content);
548 static void MSLPushImage(MSLInfo *msl_info,Image *image)
553 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
554 assert(msl_info != (MSLInfo *) NULL);
557 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
558 (n+1),sizeof(*msl_info->image_info));
559 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
560 (n+1),sizeof(*msl_info->draw_info));
561 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
562 (n+1),sizeof(*msl_info->attributes));
563 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
564 sizeof(*msl_info->image));
565 if ((msl_info->image_info == (ImageInfo **) NULL) ||
566 (msl_info->draw_info == (DrawInfo **) NULL) ||
567 (msl_info->attributes == (Image **) NULL) ||
568 (msl_info->image == (Image **) NULL))
569 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
570 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
571 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
572 msl_info->draw_info[n-1]);
573 if (image == (Image *) NULL)
574 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
576 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
577 msl_info->image[n]=(Image *) image;
578 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
579 (msl_info->attributes[n] == (Image *) NULL))
580 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
581 if (msl_info->number_groups != 0)
582 msl_info->group_info[msl_info->number_groups-1].numImages++;
585 static void MSLPopImage(MSLInfo *msl_info)
587 if (msl_info->number_groups != 0)
589 if (msl_info->image[msl_info->n] != (Image *) NULL)
590 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
591 msl_info->attributes[msl_info->n]=DestroyImage(
592 msl_info->attributes[msl_info->n]);
593 msl_info->image_info[msl_info->n]=DestroyImageInfo(
594 msl_info->image_info[msl_info->n]);
598 static void MSLStartElement(void *context,const xmlChar *tag,
599 const xmlChar **attributes)
658 Called when an opening tag has been processed.
660 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
661 " SAX.startElement(%s",tag);
662 GetExceptionInfo(&exception);
663 msl_info=(MSLInfo *) context;
665 keyword=(const char *) NULL;
667 SetGeometryInfo(&geometry_info);
668 channel=DefaultChannels;
674 if (LocaleCompare((const char *) tag,"add-noise") == 0)
685 if (msl_info->image[n] == (Image *) NULL)
687 ThrowMSLException(OptionError,"NoImagesDefined",
692 if (attributes != (const xmlChar **) NULL)
693 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
695 keyword=(const char *) attributes[i++];
696 attribute=InterpretImageProperties(msl_info->image_info[n],
697 msl_info->attributes[n],(const char *) attributes[i],
699 CloneString(&value,attribute);
705 if (LocaleCompare(keyword,"channel") == 0)
707 option=ParseChannelOption(value);
709 ThrowMSLException(OptionError,"UnrecognizedChannelType",
711 channel=(ChannelType) option;
714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
721 if (LocaleCompare(keyword,"noise") == 0)
723 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
726 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
728 noise=(NoiseType) option;
731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
737 ThrowMSLException(OptionError,"UnrecognizedAttribute",
743 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
744 noise_image=AddNoiseImage(msl_info->image[n],noise,
745 &msl_info->image[n]->exception);
746 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
747 if (noise_image == (Image *) NULL)
749 msl_info->image[n]=DestroyImage(msl_info->image[n]);
750 msl_info->image[n]=noise_image;
753 if (LocaleCompare((const char *) tag,"annotate") == 0)
761 if (msl_info->image[n] == (Image *) NULL)
763 ThrowMSLException(OptionError,"NoImagesDefined",
767 draw_info=CloneDrawInfo(msl_info->image_info[n],
768 msl_info->draw_info[n]);
770 current=draw_info->affine;
771 GetAffineMatrix(&affine);
772 if (attributes != (const xmlChar **) NULL)
773 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
775 keyword=(const char *) attributes[i++];
776 attribute=InterpretImageProperties(msl_info->image_info[n],
777 msl_info->attributes[n],(const char *) attributes[i],
779 CloneString(&value,attribute);
785 if (LocaleCompare(keyword,"affine") == 0)
791 draw_info->affine.sx=InterpretLocaleValue(p,&p);
794 draw_info->affine.rx=InterpretLocaleValue(p,&p);
797 draw_info->affine.ry=InterpretLocaleValue(p,&p);
800 draw_info->affine.sy=InterpretLocaleValue(p,&p);
803 draw_info->affine.tx=InterpretLocaleValue(p,&p);
806 draw_info->affine.ty=InterpretLocaleValue(p,&p);
809 if (LocaleCompare(keyword,"align") == 0)
811 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
814 ThrowMSLException(OptionError,"UnrecognizedAlignType",
816 draw_info->align=(AlignType) option;
819 if (LocaleCompare(keyword,"antialias") == 0)
821 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
824 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
826 draw_info->stroke_antialias=(MagickBooleanType) option;
827 draw_info->text_antialias=(MagickBooleanType) option;
830 ThrowMSLException(OptionError,"UnrecognizedAttribute",
837 if (LocaleCompare(keyword,"density") == 0)
839 CloneString(&draw_info->density,value);
842 ThrowMSLException(OptionError,"UnrecognizedAttribute",
849 if (LocaleCompare(keyword,"encoding") == 0)
851 CloneString(&draw_info->encoding,value);
854 ThrowMSLException(OptionError,"UnrecognizedAttribute",
861 if (LocaleCompare(keyword, "fill") == 0)
863 (void) QueryColorDatabase(value,&draw_info->fill,
867 if (LocaleCompare(keyword,"family") == 0)
869 CloneString(&draw_info->family,value);
872 if (LocaleCompare(keyword,"font") == 0)
874 CloneString(&draw_info->font,value);
877 ThrowMSLException(OptionError,"UnrecognizedAttribute",
884 if (LocaleCompare(keyword,"geometry") == 0)
886 flags=ParseGravityGeometry(msl_info->image[n],value,
887 &geometry,&exception);
890 if (LocaleCompare(keyword,"gravity") == 0)
892 option=ParseCommandOption(MagickGravityOptions,
895 ThrowMSLException(OptionError,"UnrecognizedGravityType",
897 draw_info->gravity=(GravityType) option;
900 ThrowMSLException(OptionError,"UnrecognizedAttribute",
907 if (LocaleCompare(keyword,"pointsize") == 0)
909 draw_info->pointsize=InterpretLocaleValue(value,
913 ThrowMSLException(OptionError,"UnrecognizedAttribute",
920 if (LocaleCompare(keyword,"rotate") == 0)
922 angle=InterpretLocaleValue(value,(char **) NULL);
923 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
924 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
925 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
926 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
929 ThrowMSLException(OptionError,"UnrecognizedAttribute",
936 if (LocaleCompare(keyword,"scale") == 0)
938 flags=ParseGeometry(value,&geometry_info);
939 if ((flags & SigmaValue) == 0)
940 geometry_info.sigma=1.0;
941 affine.sx=geometry_info.rho;
942 affine.sy=geometry_info.sigma;
945 if (LocaleCompare(keyword,"skewX") == 0)
947 angle=InterpretLocaleValue(value,(char **) NULL);
948 affine.ry=tan(DegreesToRadians(fmod((double) angle,
952 if (LocaleCompare(keyword,"skewY") == 0)
954 angle=InterpretLocaleValue(value,(char **) NULL);
955 affine.rx=tan(DegreesToRadians(fmod((double) angle,
959 if (LocaleCompare(keyword,"stretch") == 0)
961 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
964 ThrowMSLException(OptionError,"UnrecognizedStretchType",
966 draw_info->stretch=(StretchType) option;
969 if (LocaleCompare(keyword, "stroke") == 0)
971 (void) QueryColorDatabase(value,&draw_info->stroke,
975 if (LocaleCompare(keyword,"strokewidth") == 0)
977 draw_info->stroke_width=StringToLong(value);
980 if (LocaleCompare(keyword,"style") == 0)
982 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
985 ThrowMSLException(OptionError,"UnrecognizedStyleType",
987 draw_info->style=(StyleType) option;
990 ThrowMSLException(OptionError,"UnrecognizedAttribute",
997 if (LocaleCompare(keyword,"text") == 0)
999 CloneString(&draw_info->text,value);
1002 if (LocaleCompare(keyword,"translate") == 0)
1004 flags=ParseGeometry(value,&geometry_info);
1005 if ((flags & SigmaValue) == 0)
1006 geometry_info.sigma=1.0;
1007 affine.tx=geometry_info.rho;
1008 affine.ty=geometry_info.sigma;
1011 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1018 if (LocaleCompare(keyword, "undercolor") == 0)
1020 (void) QueryColorDatabase(value,&draw_info->undercolor,
1024 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1031 if (LocaleCompare(keyword,"weight") == 0)
1033 draw_info->weight=StringToLong(value);
1036 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1043 if (LocaleCompare(keyword,"x") == 0)
1045 geometry.x=StringToLong(value);
1048 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1055 if (LocaleCompare(keyword,"y") == 0)
1057 geometry.y=StringToLong(value);
1060 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1066 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1072 (void) FormatLocaleString(text,MaxTextExtent,
1073 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1074 geometry.height,(double) geometry.x,(double) geometry.y);
1075 CloneString(&draw_info->geometry,text);
1076 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1077 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1078 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1079 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1080 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1082 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1084 (void) AnnotateImage(msl_info->image[n],draw_info,
1085 &msl_info->image[n]->exception);
1086 draw_info=DestroyDrawInfo(draw_info);
1089 if (LocaleCompare((const char *) tag,"append") == 0)
1097 if (msl_info->image[n] == (Image *) NULL)
1099 ThrowMSLException(OptionError,"NoImagesDefined",
1100 (const char *) tag);
1104 if (attributes != (const xmlChar **) NULL)
1105 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1107 keyword=(const char *) attributes[i++];
1108 attribute=InterpretImageProperties(msl_info->image_info[n],
1109 msl_info->attributes[n],(const char *) attributes[i],
1111 CloneString(&value,attribute);
1117 if (LocaleCompare(keyword,"stack") == 0)
1119 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1122 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1124 stack=(MagickBooleanType) option;
1127 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1133 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1139 append_image=AppendImages(msl_info->image[n],stack,
1140 &msl_info->image[n]->exception);
1141 if (append_image == (Image *) NULL)
1143 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1144 msl_info->image[n]=append_image;
1147 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1153 if (LocaleCompare((const char *) tag,"blur") == 0)
1161 if (msl_info->image[n] == (Image *) NULL)
1163 ThrowMSLException(OptionError,"NoImagesDefined",
1164 (const char *) tag);
1167 if (attributes != (const xmlChar **) NULL)
1168 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1170 keyword=(const char *) attributes[i++];
1171 attribute=InterpretImageProperties(msl_info->image_info[n],
1172 msl_info->attributes[n],(const char *) attributes[i],
1174 CloneString(&value,attribute);
1180 if (LocaleCompare(keyword,"channel") == 0)
1182 option=ParseChannelOption(value);
1184 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1186 channel=(ChannelType) option;
1189 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1196 if (LocaleCompare(keyword,"geometry") == 0)
1198 flags=ParseGeometry(value,&geometry_info);
1199 if ((flags & SigmaValue) == 0)
1200 geometry_info.sigma=1.0;
1203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1210 if (LocaleCompare(keyword,"radius") == 0)
1212 geometry_info.rho=InterpretLocaleValue(value,
1216 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1223 if (LocaleCompare(keyword,"sigma") == 0)
1225 geometry_info.sigma=StringToLong(value);
1228 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1234 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1240 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
1241 blur_image=BlurImage(msl_info->image[n],geometry_info.rho,
1242 geometry_info.sigma,geometry_info.xi,
1243 &msl_info->image[n]->exception);
1244 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
1245 if (blur_image == (Image *) NULL)
1247 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1248 msl_info->image[n]=blur_image;
1251 if (LocaleCompare((const char *) tag,"border") == 0)
1259 if (msl_info->image[n] == (Image *) NULL)
1261 ThrowMSLException(OptionError,"NoImagesDefined",
1262 (const char *) tag);
1265 SetGeometry(msl_info->image[n],&geometry);
1266 if (attributes != (const xmlChar **) NULL)
1267 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1269 keyword=(const char *) attributes[i++];
1270 attribute=InterpretImageProperties(msl_info->image_info[n],
1271 msl_info->attributes[n],(const char *) attributes[i],
1273 CloneString(&value,attribute);
1279 if (LocaleCompare(keyword,"compose") == 0)
1281 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1284 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1286 msl_info->image[n]->compose=(CompositeOperator) option;
1289 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1296 if (LocaleCompare(keyword, "fill") == 0)
1298 (void) QueryColorDatabase(value,
1299 &msl_info->image[n]->border_color,&exception);
1302 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1309 if (LocaleCompare(keyword,"geometry") == 0)
1311 flags=ParsePageGeometry(msl_info->image[n],value,
1312 &geometry,&exception);
1313 if ((flags & HeightValue) == 0)
1314 geometry.height=geometry.width;
1317 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1324 if (LocaleCompare(keyword,"height") == 0)
1326 geometry.height=StringToLong(value);
1329 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1336 if (LocaleCompare(keyword,"width") == 0)
1338 geometry.width=StringToLong(value);
1341 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1347 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1353 border_image=BorderImage(msl_info->image[n],&geometry,
1354 &msl_info->image[n]->exception);
1355 if (border_image == (Image *) NULL)
1357 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1358 msl_info->image[n]=border_image;
1361 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1366 if (LocaleCompare((const char *) tag,"colorize") == 0)
1369 opacity[MaxTextExtent];
1380 if (msl_info->image[n] == (Image *) NULL)
1382 ThrowMSLException(OptionError,"NoImagesDefined",
1383 (const char *) tag);
1386 target=msl_info->image[n]->background_color;
1387 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1388 if (attributes != (const xmlChar **) NULL)
1389 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1391 keyword=(const char *) attributes[i++];
1392 attribute=InterpretImageProperties(msl_info->image_info[n],
1393 msl_info->attributes[n],(const char *) attributes[i],
1395 CloneString(&value,attribute);
1401 if (LocaleCompare(keyword,"fill") == 0)
1403 (void) QueryColorDatabase(value,&target,
1404 &msl_info->image[n]->exception);
1407 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1414 if (LocaleCompare(keyword,"opacity") == 0)
1416 (void) CopyMagickString(opacity,value,MaxTextExtent);
1419 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1431 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1432 &msl_info->image[n]->exception);
1433 if (colorize_image == (Image *) NULL)
1435 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1436 msl_info->image[n]=colorize_image;
1439 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1445 if (msl_info->image[n] == (Image *) NULL)
1447 ThrowMSLException(OptionError,"NoImagesDefined",
1448 (const char *) tag);
1452 NOTE: charcoal can have no attributes, since we use all the defaults!
1454 if (attributes != (const xmlChar **) NULL)
1456 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1458 keyword=(const char *) attributes[i++];
1459 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1460 msl_info->attributes[n],(const char *) attributes[i],&exception));
1466 if (LocaleCompare(keyword, "bias") == 0)
1468 bias = InterpretLocaleValue(value,(char **) NULL);
1471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1477 if (LocaleCompare(keyword, "radius") == 0)
1479 radius = InterpretLocaleValue(value,(char **) NULL);
1482 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1488 if (LocaleCompare(keyword,"sigma") == 0)
1490 sigma = StringToLong( value );
1493 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1498 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1512 newImage=CharcoalImage(msl_info->image[n],radius,sigma,bias,
1513 &msl_info->image[n]->exception);
1514 if (newImage == (Image *) NULL)
1516 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1517 msl_info->image[n]=newImage;
1521 if (LocaleCompare((const char *) tag,"chop") == 0)
1529 if (msl_info->image[n] == (Image *) NULL)
1531 ThrowMSLException(OptionError,"NoImagesDefined",
1532 (const char *) tag);
1535 SetGeometry(msl_info->image[n],&geometry);
1536 if (attributes != (const xmlChar **) NULL)
1537 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1539 keyword=(const char *) attributes[i++];
1540 attribute=InterpretImageProperties(msl_info->image_info[n],
1541 msl_info->attributes[n],(const char *) attributes[i],
1543 CloneString(&value,attribute);
1549 if (LocaleCompare(keyword,"geometry") == 0)
1551 flags=ParsePageGeometry(msl_info->image[n],value,
1552 &geometry,&exception);
1553 if ((flags & HeightValue) == 0)
1554 geometry.height=geometry.width;
1557 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1564 if (LocaleCompare(keyword,"height") == 0)
1566 geometry.height=StringToLong(value);
1569 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1576 if (LocaleCompare(keyword,"width") == 0)
1578 geometry.width=StringToLong(value);
1581 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1588 if (LocaleCompare(keyword,"x") == 0)
1590 geometry.x=StringToLong(value);
1593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1600 if (LocaleCompare(keyword,"y") == 0)
1602 geometry.y=StringToLong(value);
1605 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1611 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1617 chop_image=ChopImage(msl_info->image[n],&geometry,
1618 &msl_info->image[n]->exception);
1619 if (chop_image == (Image *) NULL)
1621 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1622 msl_info->image[n]=chop_image;
1625 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1634 Color floodfill image.
1636 if (msl_info->image[n] == (Image *) NULL)
1638 ThrowMSLException(OptionError,"NoImagesDefined",
1639 (const char *) tag);
1642 draw_info=CloneDrawInfo(msl_info->image_info[n],
1643 msl_info->draw_info[n]);
1644 SetGeometry(msl_info->image[n],&geometry);
1645 paint_method=FloodfillMethod;
1646 if (attributes != (const xmlChar **) NULL)
1647 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1649 keyword=(const char *) attributes[i++];
1650 attribute=InterpretImageProperties(msl_info->image_info[n],
1651 msl_info->attributes[n],(const char *) attributes[i],
1653 CloneString(&value,attribute);
1659 if (LocaleCompare(keyword,"bordercolor") == 0)
1661 (void) QueryMagickColor(value,&target,&exception);
1662 paint_method=FillToBorderMethod;
1665 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1672 if (LocaleCompare(keyword,"fill") == 0)
1674 (void) QueryColorDatabase(value,&draw_info->fill,
1678 if (LocaleCompare(keyword,"fuzz") == 0)
1680 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
1684 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1691 if (LocaleCompare(keyword,"geometry") == 0)
1693 flags=ParsePageGeometry(msl_info->image[n],value,
1694 &geometry,&exception);
1695 if ((flags & HeightValue) == 0)
1696 geometry.height=geometry.width;
1697 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1698 geometry.x,geometry.y,&target,&exception);
1701 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1708 if (LocaleCompare(keyword,"x") == 0)
1710 geometry.x=StringToLong(value);
1711 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1712 geometry.x,geometry.y,&target,&exception);
1715 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1722 if (LocaleCompare(keyword,"y") == 0)
1724 geometry.y=StringToLong(value);
1725 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1726 geometry.x,geometry.y,&target,&exception);
1729 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1735 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1741 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
1742 geometry.x,geometry.y,paint_method == FloodfillMethod ?
1743 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
1744 draw_info=DestroyDrawInfo(draw_info);
1747 if (LocaleCompare((const char *) tag,"comment") == 0)
1749 if (LocaleCompare((const char *) tag,"composite") == 0)
1752 composite_geometry[MaxTextExtent];
1767 if (msl_info->image[n] == (Image *) NULL)
1769 ThrowMSLException(OptionError,"NoImagesDefined",
1770 (const char *) tag);
1773 composite_image=NewImageList();
1774 compose=OverCompositeOp;
1775 if (attributes != (const xmlChar **) NULL)
1776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1778 keyword=(const char *) attributes[i++];
1779 attribute=InterpretImageProperties(msl_info->image_info[n],
1780 msl_info->attributes[n],(const char *) attributes[i],
1782 CloneString(&value,attribute);
1788 if (LocaleCompare(keyword,"compose") == 0)
1790 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1793 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1795 compose=(CompositeOperator) option;
1803 if (LocaleCompare(keyword,"image") == 0)
1804 for (j=0; j < msl_info->n; j++)
1809 attribute=GetImageProperty(msl_info->attributes[j],"id");
1810 if ((attribute != (const char *) NULL) &&
1811 (LocaleCompare(attribute,value) == 0))
1813 composite_image=CloneImage(msl_info->image[j],0,0,
1814 MagickFalse,&exception);
1824 if (composite_image == (Image *) NULL)
1826 rotate_image=NewImageList();
1827 SetGeometry(msl_info->image[n],&geometry);
1828 if (attributes != (const xmlChar **) NULL)
1829 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1831 keyword=(const char *) attributes[i++];
1832 attribute=InterpretImageProperties(msl_info->image_info[n],
1833 msl_info->attributes[n],(const char *) attributes[i],
1835 CloneString(&value,attribute);
1841 if (LocaleCompare(keyword,"blend") == 0)
1843 (void) SetImageArtifact(composite_image,
1844 "compose:args",value);
1847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1854 if (LocaleCompare(keyword,"channel") == 0)
1856 option=ParseChannelOption(value);
1858 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1860 channel=(ChannelType) option;
1863 if (LocaleCompare(keyword, "color") == 0)
1865 (void) QueryColorDatabase(value,
1866 &composite_image->background_color,&exception);
1869 if (LocaleCompare(keyword,"compose") == 0)
1871 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1878 if (LocaleCompare(keyword,"geometry") == 0)
1880 flags=ParsePageGeometry(msl_info->image[n],value,
1881 &geometry,&exception);
1882 if ((flags & HeightValue) == 0)
1883 geometry.height=geometry.width;
1884 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1885 geometry.y,&target,&exception);
1888 if (LocaleCompare(keyword,"gravity") == 0)
1890 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1893 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1895 msl_info->image[n]->gravity=(GravityType) option;
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"image") == 0)
1907 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1914 if (LocaleCompare(keyword,"mask") == 0)
1915 for (j=0; j < msl_info->n; j++)
1920 attribute=GetImageProperty(msl_info->attributes[j],"id");
1921 if ((attribute != (const char *) NULL) &&
1922 (LocaleCompare(value,value) == 0))
1924 SetImageType(composite_image,TrueColorMatteType,
1926 (void) CompositeImage(composite_image,
1927 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1931 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1938 if (LocaleCompare(keyword,"opacity") == 0)
1953 opacity=StringToLong(value);
1954 if (compose != DissolveCompositeOp)
1956 (void) SetImageOpacity(composite_image,(Quantum)
1960 (void) SetImageArtifact(msl_info->image[n],
1961 "compose:args",value);
1962 if (composite_image->matte != MagickTrue)
1963 (void) SetImageOpacity(composite_image,OpaqueAlpha);
1964 composite_view=AcquireCacheView(composite_image);
1965 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1967 q=GetCacheViewAuthenticPixels(composite_view,0,y,
1968 (ssize_t) composite_image->columns,1,&exception);
1969 for (x=0; x < (ssize_t) composite_image->columns; x++)
1971 if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
1972 SetPixelAlpha(composite_image,
1973 ClampToQuantum(opacity),q);
1974 q+=GetPixelChannels(composite_image);
1976 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1979 composite_view=DestroyCacheView(composite_view);
1982 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1989 if (LocaleCompare(keyword,"rotate") == 0)
1991 rotate_image=RotateImage(composite_image,
1992 InterpretLocaleValue(value,(char **) NULL),&exception);
1995 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2002 if (LocaleCompare(keyword,"tile") == 0)
2007 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2010 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2012 tile=(MagickBooleanType) option;
2014 if (rotate_image != (Image *) NULL)
2015 (void) SetImageArtifact(rotate_image,
2016 "compose:outside-overlay","false");
2018 (void) SetImageArtifact(composite_image,
2019 "compose:outside-overlay","false");
2020 image=msl_info->image[n];
2021 height=composite_image->rows;
2022 width=composite_image->columns;
2023 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
2024 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
2026 if (rotate_image != (Image *) NULL)
2027 (void) CompositeImage(image,compose,rotate_image,
2030 (void) CompositeImage(image,compose,
2031 composite_image,x,y);
2033 if (rotate_image != (Image *) NULL)
2034 rotate_image=DestroyImage(rotate_image);
2037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2044 if (LocaleCompare(keyword,"x") == 0)
2046 geometry.x=StringToLong(value);
2047 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2048 geometry.y,&target,&exception);
2051 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2058 if (LocaleCompare(keyword,"y") == 0)
2060 geometry.y=StringToLong(value);
2061 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2062 geometry.y,&target,&exception);
2065 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2071 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2077 image=msl_info->image[n];
2078 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
2079 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2080 (double) composite_image->rows,(double) geometry.x,(double)
2082 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2084 channel_mask=SetPixelChannelMask(image,channel);
2085 if (rotate_image == (Image *) NULL)
2086 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
2092 geometry.x-=(ssize_t) (rotate_image->columns-
2093 composite_image->columns)/2;
2094 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2095 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
2096 rotate_image=DestroyImage(rotate_image);
2098 (void) SetPixelChannelMask(image,channel_mask);
2099 composite_image=DestroyImage(composite_image);
2102 if (LocaleCompare((const char *) tag,"contrast") == 0)
2110 if (msl_info->image[n] == (Image *) NULL)
2112 ThrowMSLException(OptionError,"NoImagesDefined",
2113 (const char *) tag);
2116 sharpen=MagickFalse;
2117 if (attributes != (const xmlChar **) NULL)
2118 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2120 keyword=(const char *) attributes[i++];
2121 attribute=InterpretImageProperties(msl_info->image_info[n],
2122 msl_info->attributes[n],(const char *) attributes[i],
2124 CloneString(&value,attribute);
2130 if (LocaleCompare(keyword,"sharpen") == 0)
2132 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2135 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2137 sharpen=(MagickBooleanType) option;
2140 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2152 (void) ContrastImage(msl_info->image[n],sharpen,
2153 &msl_info->image[n]->exception);
2156 if (LocaleCompare((const char *) tag,"crop") == 0)
2164 if (msl_info->image[n] == (Image *) NULL)
2166 ThrowMSLException(OptionError,"NoImagesDefined",
2167 (const char *) tag);
2170 SetGeometry(msl_info->image[n],&geometry);
2171 if (attributes != (const xmlChar **) NULL)
2172 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2174 keyword=(const char *) attributes[i++];
2175 attribute=InterpretImageProperties(msl_info->image_info[n],
2176 msl_info->attributes[n],(const char *) attributes[i],
2178 CloneString(&value,attribute);
2184 if (LocaleCompare(keyword,"geometry") == 0)
2186 flags=ParseGravityGeometry(msl_info->image[n],value,
2187 &geometry,&exception);
2190 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2197 if (LocaleCompare(keyword,"height") == 0)
2199 geometry.height=StringToLong(value);
2202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2209 if (LocaleCompare(keyword,"width") == 0)
2211 geometry.width=StringToLong(value);
2214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2221 if (LocaleCompare(keyword,"x") == 0)
2223 geometry.x=StringToLong(value);
2226 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2233 if (LocaleCompare(keyword,"y") == 0)
2235 geometry.y=StringToLong(value);
2238 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2244 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2250 crop_image=CropImage(msl_info->image[n],&geometry,
2251 &msl_info->image[n]->exception);
2252 if (crop_image == (Image *) NULL)
2254 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2255 msl_info->image[n]=crop_image;
2258 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2264 Cycle-colormap image.
2266 if (msl_info->image[n] == (Image *) NULL)
2268 ThrowMSLException(OptionError,"NoImagesDefined",
2269 (const char *) tag);
2273 if (attributes != (const xmlChar **) NULL)
2274 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2276 keyword=(const char *) attributes[i++];
2277 attribute=InterpretImageProperties(msl_info->image_info[n],
2278 msl_info->attributes[n],(const char *) attributes[i],
2280 CloneString(&value,attribute);
2286 if (LocaleCompare(keyword,"display") == 0)
2288 display=StringToLong(value);
2291 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2297 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2303 (void) CycleColormapImage(msl_info->image[n],display,&exception);
2306 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2311 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2319 if (msl_info->image[n] == (Image *) NULL)
2321 ThrowMSLException(OptionError,"NoImagesDefined",
2322 (const char *) tag);
2325 if (attributes != (const xmlChar **) NULL)
2326 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2328 keyword=(const char *) attributes[i++];
2329 attribute=InterpretImageProperties(msl_info->image_info[n],
2330 msl_info->attributes[n],(const char *) attributes[i],
2332 CloneString(&value,attribute);
2333 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2335 despeckle_image=DespeckleImage(msl_info->image[n],
2336 &msl_info->image[n]->exception);
2337 if (despeckle_image == (Image *) NULL)
2339 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2340 msl_info->image[n]=despeckle_image;
2343 if (LocaleCompare((const char *) tag,"display") == 0)
2345 if (msl_info->image[n] == (Image *) NULL)
2347 ThrowMSLException(OptionError,"NoImagesDefined",
2348 (const char *) tag);
2351 if (attributes != (const xmlChar **) NULL)
2352 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2354 keyword=(const char *) attributes[i++];
2355 attribute=InterpretImageProperties(msl_info->image_info[n],
2356 msl_info->attributes[n],(const char *) attributes[i],
2358 CloneString(&value,attribute);
2363 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2369 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n],
2370 &msl_info->image[n]->exception);
2373 if (LocaleCompare((const char *) tag,"draw") == 0)
2376 text[MaxTextExtent];
2381 if (msl_info->image[n] == (Image *) NULL)
2383 ThrowMSLException(OptionError,"NoImagesDefined",
2384 (const char *) tag);
2387 draw_info=CloneDrawInfo(msl_info->image_info[n],
2388 msl_info->draw_info[n]);
2390 current=draw_info->affine;
2391 GetAffineMatrix(&affine);
2392 if (attributes != (const xmlChar **) NULL)
2393 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2395 keyword=(const char *) attributes[i++];
2396 attribute=InterpretImageProperties(msl_info->image_info[n],
2397 msl_info->attributes[n],(const char *) attributes[i],
2399 CloneString(&value,attribute);
2405 if (LocaleCompare(keyword,"affine") == 0)
2411 draw_info->affine.sx=InterpretLocaleValue(p,&p);
2414 draw_info->affine.rx=InterpretLocaleValue(p,&p);
2417 draw_info->affine.ry=InterpretLocaleValue(p,&p);
2420 draw_info->affine.sy=InterpretLocaleValue(p,&p);
2423 draw_info->affine.tx=InterpretLocaleValue(p,&p);
2426 draw_info->affine.ty=InterpretLocaleValue(p,&p);
2429 if (LocaleCompare(keyword,"align") == 0)
2431 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2434 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2436 draw_info->align=(AlignType) option;
2439 if (LocaleCompare(keyword,"antialias") == 0)
2441 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2444 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2446 draw_info->stroke_antialias=(MagickBooleanType) option;
2447 draw_info->text_antialias=(MagickBooleanType) option;
2450 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2457 if (LocaleCompare(keyword,"density") == 0)
2459 CloneString(&draw_info->density,value);
2462 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2469 if (LocaleCompare(keyword,"encoding") == 0)
2471 CloneString(&draw_info->encoding,value);
2474 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2481 if (LocaleCompare(keyword, "fill") == 0)
2483 (void) QueryColorDatabase(value,&draw_info->fill,
2487 if (LocaleCompare(keyword,"family") == 0)
2489 CloneString(&draw_info->family,value);
2492 if (LocaleCompare(keyword,"font") == 0)
2494 CloneString(&draw_info->font,value);
2497 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2504 if (LocaleCompare(keyword,"geometry") == 0)
2506 flags=ParsePageGeometry(msl_info->image[n],value,
2507 &geometry,&exception);
2508 if ((flags & HeightValue) == 0)
2509 geometry.height=geometry.width;
2512 if (LocaleCompare(keyword,"gravity") == 0)
2514 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2517 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2519 draw_info->gravity=(GravityType) option;
2522 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2529 if (LocaleCompare(keyword,"primitive") == 0)
2531 CloneString(&draw_info->primitive,value);
2534 if (LocaleCompare(keyword,"pointsize") == 0)
2536 draw_info->pointsize=InterpretLocaleValue(value,
2540 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2547 if (LocaleCompare(keyword,"rotate") == 0)
2549 angle=InterpretLocaleValue(value,(char **) NULL);
2550 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2551 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2552 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2553 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2556 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2563 if (LocaleCompare(keyword,"scale") == 0)
2565 flags=ParseGeometry(value,&geometry_info);
2566 if ((flags & SigmaValue) == 0)
2567 geometry_info.sigma=1.0;
2568 affine.sx=geometry_info.rho;
2569 affine.sy=geometry_info.sigma;
2572 if (LocaleCompare(keyword,"skewX") == 0)
2574 angle=InterpretLocaleValue(value,(char **) NULL);
2575 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2578 if (LocaleCompare(keyword,"skewY") == 0)
2580 angle=InterpretLocaleValue(value,(char **) NULL);
2581 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2584 if (LocaleCompare(keyword,"stretch") == 0)
2586 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2589 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2591 draw_info->stretch=(StretchType) option;
2594 if (LocaleCompare(keyword, "stroke") == 0)
2596 (void) QueryColorDatabase(value,&draw_info->stroke,
2600 if (LocaleCompare(keyword,"strokewidth") == 0)
2602 draw_info->stroke_width=StringToLong(value);
2605 if (LocaleCompare(keyword,"style") == 0)
2607 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2610 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2612 draw_info->style=(StyleType) option;
2615 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2622 if (LocaleCompare(keyword,"text") == 0)
2624 CloneString(&draw_info->text,value);
2627 if (LocaleCompare(keyword,"translate") == 0)
2629 flags=ParseGeometry(value,&geometry_info);
2630 if ((flags & SigmaValue) == 0)
2631 geometry_info.sigma=1.0;
2632 affine.tx=geometry_info.rho;
2633 affine.ty=geometry_info.sigma;
2636 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2643 if (LocaleCompare(keyword, "undercolor") == 0)
2645 (void) QueryColorDatabase(value,&draw_info->undercolor,
2649 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 if (LocaleCompare(keyword,"weight") == 0)
2658 draw_info->weight=StringToLong(value);
2661 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2668 if (LocaleCompare(keyword,"x") == 0)
2670 geometry.x=StringToLong(value);
2673 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2680 if (LocaleCompare(keyword,"y") == 0)
2682 geometry.y=StringToLong(value);
2685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2691 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2697 (void) FormatLocaleString(text,MaxTextExtent,
2698 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2699 geometry.height,(double) geometry.x,(double) geometry.y);
2700 CloneString(&draw_info->geometry,text);
2701 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2702 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2703 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2704 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2705 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2707 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2709 (void) DrawImage(msl_info->image[n],draw_info,&exception);
2710 draw_info=DestroyDrawInfo(draw_info);
2713 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2718 if (LocaleCompare((const char *) tag,"edge") == 0)
2726 if (msl_info->image[n] == (Image *) NULL)
2728 ThrowMSLException(OptionError,"NoImagesDefined",
2729 (const char *) tag);
2732 if (attributes != (const xmlChar **) NULL)
2733 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2735 keyword=(const char *) attributes[i++];
2736 attribute=InterpretImageProperties(msl_info->image_info[n],
2737 msl_info->attributes[n],(const char *) attributes[i],
2739 CloneString(&value,attribute);
2745 if (LocaleCompare(keyword,"geometry") == 0)
2747 flags=ParseGeometry(value,&geometry_info);
2748 if ((flags & SigmaValue) == 0)
2749 geometry_info.sigma=1.0;
2752 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2759 if (LocaleCompare(keyword,"radius") == 0)
2761 geometry_info.rho=InterpretLocaleValue(value,
2765 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2771 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2777 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2778 geometry_info.sigma,&msl_info->image[n]->exception);
2779 if (edge_image == (Image *) NULL)
2781 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2782 msl_info->image[n]=edge_image;
2785 if (LocaleCompare((const char *) tag,"emboss") == 0)
2793 if (msl_info->image[n] == (Image *) NULL)
2795 ThrowMSLException(OptionError,"NoImagesDefined",
2796 (const char *) tag);
2799 if (attributes != (const xmlChar **) NULL)
2800 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2802 keyword=(const char *) attributes[i++];
2803 attribute=InterpretImageProperties(msl_info->image_info[n],
2804 msl_info->attributes[n],(const char *) attributes[i],
2806 CloneString(&value,attribute);
2812 if (LocaleCompare(keyword,"geometry") == 0)
2814 flags=ParseGeometry(value,&geometry_info);
2815 if ((flags & SigmaValue) == 0)
2816 geometry_info.sigma=1.0;
2819 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2826 if (LocaleCompare(keyword,"radius") == 0)
2828 geometry_info.rho=InterpretLocaleValue(value,
2832 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2839 if (LocaleCompare(keyword,"sigma") == 0)
2841 geometry_info.sigma=StringToLong(value);
2844 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2850 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2856 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2857 geometry_info.sigma,&msl_info->image[n]->exception);
2858 if (emboss_image == (Image *) NULL)
2860 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2861 msl_info->image[n]=emboss_image;
2864 if (LocaleCompare((const char *) tag,"enhance") == 0)
2872 if (msl_info->image[n] == (Image *) NULL)
2874 ThrowMSLException(OptionError,"NoImagesDefined",
2875 (const char *) tag);
2878 if (attributes != (const xmlChar **) NULL)
2879 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2881 keyword=(const char *) attributes[i++];
2882 attribute=InterpretImageProperties(msl_info->image_info[n],
2883 msl_info->attributes[n],(const char *) attributes[i],
2885 CloneString(&value,attribute);
2886 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2888 enhance_image=EnhanceImage(msl_info->image[n],
2889 &msl_info->image[n]->exception);
2890 if (enhance_image == (Image *) NULL)
2892 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2893 msl_info->image[n]=enhance_image;
2896 if (LocaleCompare((const char *) tag,"equalize") == 0)
2901 if (msl_info->image[n] == (Image *) NULL)
2903 ThrowMSLException(OptionError,"NoImagesDefined",
2904 (const char *) tag);
2907 if (attributes != (const xmlChar **) NULL)
2908 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2910 keyword=(const char *) attributes[i++];
2911 attribute=InterpretImageProperties(msl_info->image_info[n],
2912 msl_info->attributes[n],(const char *) attributes[i],
2914 CloneString(&value,attribute);
2919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2925 (void) EqualizeImage(msl_info->image[n],
2926 &msl_info->image[n]->exception);
2929 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2934 if (LocaleCompare((const char *) tag, "flatten") == 0)
2936 if (msl_info->image[n] == (Image *) NULL)
2938 ThrowMSLException(OptionError,"NoImagesDefined",
2939 (const char *) tag);
2943 /* no attributes here */
2945 /* process the image */
2950 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2951 &msl_info->image[n]->exception);
2952 if (newImage == (Image *) NULL)
2954 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2955 msl_info->image[n]=newImage;
2959 if (LocaleCompare((const char *) tag,"flip") == 0)
2967 if (msl_info->image[n] == (Image *) NULL)
2969 ThrowMSLException(OptionError,"NoImagesDefined",
2970 (const char *) tag);
2973 if (attributes != (const xmlChar **) NULL)
2974 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2976 keyword=(const char *) attributes[i++];
2977 attribute=InterpretImageProperties(msl_info->image_info[n],
2978 msl_info->attributes[n],(const char *) attributes[i],
2980 CloneString(&value,attribute);
2981 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2983 flip_image=FlipImage(msl_info->image[n],
2984 &msl_info->image[n]->exception);
2985 if (flip_image == (Image *) NULL)
2987 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2988 msl_info->image[n]=flip_image;
2991 if (LocaleCompare((const char *) tag,"flop") == 0)
2999 if (msl_info->image[n] == (Image *) NULL)
3001 ThrowMSLException(OptionError,"NoImagesDefined",
3002 (const char *) tag);
3005 if (attributes != (const xmlChar **) NULL)
3006 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3008 keyword=(const char *) attributes[i++];
3009 attribute=InterpretImageProperties(msl_info->image_info[n],
3010 msl_info->attributes[n],(const char *) attributes[i],
3012 CloneString(&value,attribute);
3013 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3015 flop_image=FlopImage(msl_info->image[n],
3016 &msl_info->image[n]->exception);
3017 if (flop_image == (Image *) NULL)
3019 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3020 msl_info->image[n]=flop_image;
3023 if (LocaleCompare((const char *) tag,"frame") == 0)
3034 if (msl_info->image[n] == (Image *) NULL)
3036 ThrowMSLException(OptionError,"NoImagesDefined",
3037 (const char *) tag);
3040 SetGeometry(msl_info->image[n],&geometry);
3041 if (attributes != (const xmlChar **) NULL)
3042 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3044 keyword=(const char *) attributes[i++];
3045 attribute=InterpretImageProperties(msl_info->image_info[n],
3046 msl_info->attributes[n],(const char *) attributes[i],
3048 CloneString(&value,attribute);
3054 if (LocaleCompare(keyword,"compose") == 0)
3056 option=ParseCommandOption(MagickComposeOptions,
3059 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3061 msl_info->image[n]->compose=(CompositeOperator) option;
3064 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3071 if (LocaleCompare(keyword, "fill") == 0)
3073 (void) QueryColorDatabase(value,
3074 &msl_info->image[n]->matte_color,&exception);
3077 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3084 if (LocaleCompare(keyword,"geometry") == 0)
3086 flags=ParsePageGeometry(msl_info->image[n],value,
3087 &geometry,&exception);
3088 if ((flags & HeightValue) == 0)
3089 geometry.height=geometry.width;
3090 frame_info.width=geometry.width;
3091 frame_info.height=geometry.height;
3092 frame_info.outer_bevel=geometry.x;
3093 frame_info.inner_bevel=geometry.y;
3096 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3103 if (LocaleCompare(keyword,"height") == 0)
3105 frame_info.height=StringToLong(value);
3108 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3115 if (LocaleCompare(keyword,"inner") == 0)
3117 frame_info.inner_bevel=StringToLong(value);
3120 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3127 if (LocaleCompare(keyword,"outer") == 0)
3129 frame_info.outer_bevel=StringToLong(value);
3132 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3139 if (LocaleCompare(keyword,"width") == 0)
3141 frame_info.width=StringToLong(value);
3144 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3150 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3156 frame_info.x=(ssize_t) frame_info.width;
3157 frame_info.y=(ssize_t) frame_info.height;
3158 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3159 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3160 frame_image=FrameImage(msl_info->image[n],&frame_info,
3161 &msl_info->image[n]->exception);
3162 if (frame_image == (Image *) NULL)
3164 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3165 msl_info->image[n]=frame_image;
3168 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3173 if (LocaleCompare((const char *) tag,"gamma") == 0)
3176 gamma[MaxTextExtent];
3184 if (msl_info->image[n] == (Image *) NULL)
3186 ThrowMSLException(OptionError,"NoImagesDefined",
3187 (const char *) tag);
3190 channel=UndefinedChannel;
3195 if (attributes != (const xmlChar **) NULL)
3196 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3198 keyword=(const char *) attributes[i++];
3199 attribute=InterpretImageProperties(msl_info->image_info[n],
3200 msl_info->attributes[n],(const char *) attributes[i],
3202 CloneString(&value,attribute);
3208 if (LocaleCompare(keyword,"blue") == 0)
3210 pixel.blue=InterpretLocaleValue(value,(char **) NULL);
3213 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3220 if (LocaleCompare(keyword,"channel") == 0)
3222 option=ParseChannelOption(value);
3224 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3226 channel=(ChannelType) option;
3229 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3236 if (LocaleCompare(keyword,"gamma") == 0)
3238 (void) CopyMagickString(gamma,value,MaxTextExtent);
3241 if (LocaleCompare(keyword,"green") == 0)
3243 pixel.green=InterpretLocaleValue(value,(char **) NULL);
3246 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3253 if (LocaleCompare(keyword,"red") == 0)
3255 pixel.red=InterpretLocaleValue(value,(char **) NULL);
3258 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3264 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3271 (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g",
3272 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3273 (void) GammaImage(msl_info->image[n],atof(gamma),
3274 &msl_info->image[n]->exception);
3277 else if (LocaleCompare((const char *) tag,"get") == 0)
3279 if (msl_info->image[n] == (Image *) NULL)
3281 ThrowMSLException(OptionError,"NoImagesDefined",
3282 (const char *) tag);
3285 if (attributes == (const xmlChar **) NULL)
3287 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3289 keyword=(const char *) attributes[i++];
3290 CloneString(&value,(const char *) attributes[i]);
3291 (void) CopyMagickString(key,value,MaxTextExtent);
3297 if (LocaleCompare(keyword,"height") == 0)
3299 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3300 (double) msl_info->image[n]->rows);
3301 (void) SetImageProperty(msl_info->attributes[n],key,value);
3304 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3309 if (LocaleCompare(keyword,"width") == 0)
3311 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
3312 (double) msl_info->image[n]->columns);
3313 (void) SetImageProperty(msl_info->attributes[n],key,value);
3316 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3320 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3327 else if (LocaleCompare((const char *) tag, "group") == 0)
3329 msl_info->number_groups++;
3330 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3331 msl_info->group_info,msl_info->number_groups+1UL,
3332 sizeof(*msl_info->group_info));
3335 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3340 if (LocaleCompare((const char *) tag,"image") == 0)
3342 MSLPushImage(msl_info,(Image *) NULL);
3343 if (attributes == (const xmlChar **) NULL)
3345 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3347 keyword=(const char *) attributes[i++];
3348 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3349 msl_info->attributes[n],(const char *) attributes[i],&exception));
3355 if (LocaleCompare(keyword,"color") == 0)
3360 (void) CopyMagickString(msl_info->image_info[n]->filename,
3361 "xc:",MaxTextExtent);
3362 (void) ConcatenateMagickString(msl_info->image_info[n]->
3363 filename,value,MaxTextExtent);
3364 next_image=ReadImage(msl_info->image_info[n],&exception);
3365 CatchException(&exception);
3366 if (next_image == (Image *) NULL)
3368 if (msl_info->image[n] == (Image *) NULL)
3369 msl_info->image[n]=next_image;
3376 Link image into image list.
3378 p=msl_info->image[n];
3379 while (p->next != (Image *) NULL)
3380 p=GetNextImageInList(p);
3381 next_image->previous=p;
3386 (void) SetMSLAttributes(msl_info,keyword,value);
3391 (void) SetMSLAttributes(msl_info,keyword,value);
3398 if (LocaleCompare((const char *) tag,"implode") == 0)
3406 if (msl_info->image[n] == (Image *) NULL)
3408 ThrowMSLException(OptionError,"NoImagesDefined",
3409 (const char *) tag);
3412 if (attributes != (const xmlChar **) NULL)
3413 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3415 keyword=(const char *) attributes[i++];
3416 attribute=InterpretImageProperties(msl_info->image_info[n],
3417 msl_info->attributes[n],(const char *) attributes[i],
3419 CloneString(&value,attribute);
3425 if (LocaleCompare(keyword,"amount") == 0)
3427 geometry_info.rho=InterpretLocaleValue(value,
3431 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3438 if (LocaleCompare(keyword,"geometry") == 0)
3440 flags=ParseGeometry(value,&geometry_info);
3441 if ((flags & SigmaValue) == 0)
3442 geometry_info.sigma=1.0;
3445 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3451 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3457 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3458 &msl_info->image[n]->exception);
3459 if (implode_image == (Image *) NULL)
3461 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3462 msl_info->image[n]=implode_image;
3465 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3470 if (LocaleCompare((const char *) tag,"label") == 0)
3472 if (LocaleCompare((const char *) tag, "level") == 0)
3475 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3477 if (msl_info->image[n] == (Image *) NULL)
3479 ThrowMSLException(OptionError,"NoImagesDefined",
3480 (const char *) tag);
3483 if (attributes == (const xmlChar **) NULL)
3485 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3487 keyword=(const char *) attributes[i++];
3488 CloneString(&value,(const char *) attributes[i]);
3489 (void) CopyMagickString(key,value,MaxTextExtent);
3495 if (LocaleCompare(keyword,"black") == 0)
3497 levelBlack = InterpretLocaleValue(value,(char **) NULL);
3500 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3506 if (LocaleCompare(keyword,"gamma") == 0)
3508 levelGamma = InterpretLocaleValue(value,(char **) NULL);
3511 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3517 if (LocaleCompare(keyword,"white") == 0)
3519 levelWhite = InterpretLocaleValue(value,(char **) NULL);
3522 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3527 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3534 LevelImage(msl_info->image[n],levelBlack,levelWhite,levelGamma,
3535 &msl_info->image[n]->exception);
3542 if (LocaleCompare((const char *) tag,"magnify") == 0)
3550 if (msl_info->image[n] == (Image *) NULL)
3552 ThrowMSLException(OptionError,"NoImagesDefined",
3553 (const char *) tag);
3556 if (attributes != (const xmlChar **) NULL)
3557 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3559 keyword=(const char *) attributes[i++];
3560 attribute=InterpretImageProperties(msl_info->image_info[n],
3561 msl_info->attributes[n],(const char *) attributes[i],
3563 CloneString(&value,attribute);
3564 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3566 magnify_image=MagnifyImage(msl_info->image[n],
3567 &msl_info->image[n]->exception);
3568 if (magnify_image == (Image *) NULL)
3570 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3571 msl_info->image[n]=magnify_image;
3574 if (LocaleCompare((const char *) tag,"map") == 0)
3588 if (msl_info->image[n] == (Image *) NULL)
3590 ThrowMSLException(OptionError,"NoImagesDefined",
3591 (const char *) tag);
3594 affinity_image=NewImageList();
3596 if (attributes != (const xmlChar **) NULL)
3597 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3599 keyword=(const char *) attributes[i++];
3600 attribute=InterpretImageProperties(msl_info->image_info[n],
3601 msl_info->attributes[n],(const char *) attributes[i],
3603 CloneString(&value,attribute);
3609 if (LocaleCompare(keyword,"dither") == 0)
3611 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3614 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3616 dither=(MagickBooleanType) option;
3619 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3626 if (LocaleCompare(keyword,"image") == 0)
3627 for (j=0; j < msl_info->n; j++)
3632 attribute=GetImageProperty(msl_info->attributes[j],"id");
3633 if ((attribute != (const char *) NULL) &&
3634 (LocaleCompare(attribute,value) == 0))
3636 affinity_image=CloneImage(msl_info->image[j],0,0,
3637 MagickFalse,&exception);
3645 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3651 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3652 quantize_info->dither=dither;
3653 (void) RemapImages(quantize_info,msl_info->image[n],
3654 affinity_image,&exception);
3655 quantize_info=DestroyQuantizeInfo(quantize_info);
3656 affinity_image=DestroyImage(affinity_image);
3659 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3671 Matte floodfill image.
3674 if (msl_info->image[n] == (Image *) NULL)
3676 ThrowMSLException(OptionError,"NoImagesDefined",
3677 (const char *) tag);
3680 SetGeometry(msl_info->image[n],&geometry);
3681 paint_method=FloodfillMethod;
3682 if (attributes != (const xmlChar **) NULL)
3683 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3685 keyword=(const char *) attributes[i++];
3686 attribute=InterpretImageProperties(msl_info->image_info[n],
3687 msl_info->attributes[n],(const char *) attributes[i],
3689 CloneString(&value,attribute);
3695 if (LocaleCompare(keyword,"bordercolor") == 0)
3697 (void) QueryMagickColor(value,&target,&exception);
3698 paint_method=FillToBorderMethod;
3701 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3708 if (LocaleCompare(keyword,"fuzz") == 0)
3710 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
3714 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3721 if (LocaleCompare(keyword,"geometry") == 0)
3723 flags=ParsePageGeometry(msl_info->image[n],value,
3724 &geometry,&exception);
3725 if ((flags & HeightValue) == 0)
3726 geometry.height=geometry.width;
3727 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3728 geometry.x,geometry.y,&target,&exception);
3731 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3738 if (LocaleCompare(keyword,"opacity") == 0)
3740 opacity=InterpretLocaleValue(value,(char **) NULL);
3743 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3750 if (LocaleCompare(keyword,"x") == 0)
3752 geometry.x=StringToLong(value);
3753 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3754 geometry.x,geometry.y,&target,&exception);
3757 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3764 if (LocaleCompare(keyword,"y") == 0)
3766 geometry.y=StringToLong(value);
3767 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3768 geometry.x,geometry.y,&target,&exception);
3771 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3777 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3783 draw_info=CloneDrawInfo(msl_info->image_info[n],
3784 msl_info->draw_info[n]);
3785 draw_info->fill.alpha=ClampToQuantum(opacity);
3786 channel_mask=SetPixelChannelMask(msl_info->image[n],AlphaChannel);
3787 (void) FloodfillPaintImage(msl_info->image[n],draw_info,&target,
3788 geometry.x,geometry.y,paint_method == FloodfillMethod ?
3789 MagickFalse : MagickTrue,&msl_info->image[n]->exception);
3790 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
3791 draw_info=DestroyDrawInfo(draw_info);
3794 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3800 Median-filter image.
3802 if (msl_info->image[n] == (Image *) NULL)
3804 ThrowMSLException(OptionError,"NoImagesDefined",
3805 (const char *) tag);
3808 if (attributes != (const xmlChar **) NULL)
3809 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3811 keyword=(const char *) attributes[i++];
3812 attribute=InterpretImageProperties(msl_info->image_info[n],
3813 msl_info->attributes[n],(const char *) attributes[i],
3815 CloneString(&value,attribute);
3821 if (LocaleCompare(keyword,"geometry") == 0)
3823 flags=ParseGeometry(value,&geometry_info);
3824 if ((flags & SigmaValue) == 0)
3825 geometry_info.sigma=1.0;
3828 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3835 if (LocaleCompare(keyword,"radius") == 0)
3837 geometry_info.rho=InterpretLocaleValue(value,
3841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3847 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3853 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3854 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3855 &msl_info->image[n]->exception);
3856 if (median_image == (Image *) NULL)
3858 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3859 msl_info->image[n]=median_image;
3862 if (LocaleCompare((const char *) tag,"minify") == 0)
3870 if (msl_info->image[n] == (Image *) NULL)
3872 ThrowMSLException(OptionError,"NoImagesDefined",
3873 (const char *) tag);
3876 if (attributes != (const xmlChar **) NULL)
3877 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3879 keyword=(const char *) attributes[i++];
3880 attribute=InterpretImageProperties(msl_info->image_info[n],
3881 msl_info->attributes[n],(const char *) attributes[i],
3883 CloneString(&value,attribute);
3884 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3886 minify_image=MinifyImage(msl_info->image[n],
3887 &msl_info->image[n]->exception);
3888 if (minify_image == (Image *) NULL)
3890 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3891 msl_info->image[n]=minify_image;
3894 if (LocaleCompare((const char *) tag,"msl") == 0 )
3896 if (LocaleCompare((const char *) tag,"modulate") == 0)
3899 modulate[MaxTextExtent];
3904 if (msl_info->image[n] == (Image *) NULL)
3906 ThrowMSLException(OptionError,"NoImagesDefined",
3907 (const char *) tag);
3910 geometry_info.rho=100.0;
3911 geometry_info.sigma=100.0;
3912 geometry_info.xi=100.0;
3913 if (attributes != (const xmlChar **) NULL)
3914 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3916 keyword=(const char *) attributes[i++];
3917 attribute=InterpretImageProperties(msl_info->image_info[n],
3918 msl_info->attributes[n],(const char *) attributes[i],
3920 CloneString(&value,attribute);
3926 if (LocaleCompare(keyword,"blackness") == 0)
3928 geometry_info.rho=InterpretLocaleValue(value,
3932 if (LocaleCompare(keyword,"brightness") == 0)
3934 geometry_info.rho=InterpretLocaleValue(value,
3938 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3945 if (LocaleCompare(keyword,"factor") == 0)
3947 flags=ParseGeometry(value,&geometry_info);
3950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3957 if (LocaleCompare(keyword,"hue") == 0)
3959 geometry_info.xi=InterpretLocaleValue(value,
3963 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3970 if (LocaleCompare(keyword,"lightness") == 0)
3972 geometry_info.rho=InterpretLocaleValue(value,
3976 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3983 if (LocaleCompare(keyword,"saturation") == 0)
3985 geometry_info.sigma=InterpretLocaleValue(value,
3989 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3996 if (LocaleCompare(keyword,"whiteness") == 0)
3998 geometry_info.sigma=InterpretLocaleValue(value,
4002 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4008 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4014 (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g",
4015 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
4016 (void) ModulateImage(msl_info->image[n],modulate,
4017 &msl_info->image[n]->exception);
4020 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4025 if (LocaleCompare((const char *) tag,"negate") == 0)
4033 if (msl_info->image[n] == (Image *) NULL)
4035 ThrowMSLException(OptionError,"NoImagesDefined",
4036 (const char *) tag);
4040 if (attributes != (const xmlChar **) NULL)
4041 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4043 keyword=(const char *) attributes[i++];
4044 attribute=InterpretImageProperties(msl_info->image_info[n],
4045 msl_info->attributes[n],(const char *) attributes[i],
4047 CloneString(&value,attribute);
4053 if (LocaleCompare(keyword,"channel") == 0)
4055 option=ParseChannelOption(value);
4057 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4059 channel=(ChannelType) option;
4062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4069 if (LocaleCompare(keyword,"gray") == 0)
4071 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4074 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4076 gray=(MagickBooleanType) option;
4079 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4085 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4091 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4092 (void) NegateImage(msl_info->image[n],gray,
4093 &msl_info->image[n]->exception);
4094 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4097 if (LocaleCompare((const char *) tag,"normalize") == 0)
4102 if (msl_info->image[n] == (Image *) NULL)
4104 ThrowMSLException(OptionError,"NoImagesDefined",
4105 (const char *) tag);
4108 if (attributes != (const xmlChar **) NULL)
4109 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4111 keyword=(const char *) attributes[i++];
4112 attribute=InterpretImageProperties(msl_info->image_info[n],
4113 msl_info->attributes[n],(const char *) attributes[i],
4115 CloneString(&value,attribute);
4121 if (LocaleCompare(keyword,"channel") == 0)
4123 option=ParseChannelOption(value);
4125 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4127 channel=(ChannelType) option;
4130 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4136 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4142 (void) NormalizeImage(msl_info->image[n],
4143 &msl_info->image[n]->exception);
4146 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4151 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4159 if (msl_info->image[n] == (Image *) NULL)
4161 ThrowMSLException(OptionError,"NoImagesDefined",
4162 (const char *) tag);
4165 if (attributes != (const xmlChar **) NULL)
4166 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4168 keyword=(const char *) attributes[i++];
4169 attribute=InterpretImageProperties(msl_info->image_info[n],
4170 msl_info->attributes[n],(const char *) attributes[i],
4172 CloneString(&value,attribute);
4178 if (LocaleCompare(keyword,"geometry") == 0)
4180 flags=ParseGeometry(value,&geometry_info);
4181 if ((flags & SigmaValue) == 0)
4182 geometry_info.sigma=1.0;
4185 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4192 if (LocaleCompare(keyword,"radius") == 0)
4194 geometry_info.rho=InterpretLocaleValue(value,
4198 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4210 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4211 geometry_info.sigma,&msl_info->image[n]->exception);
4212 if (paint_image == (Image *) NULL)
4214 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4215 msl_info->image[n]=paint_image;
4218 if (LocaleCompare((const char *) tag,"opaque") == 0)
4227 if (msl_info->image[n] == (Image *) NULL)
4229 ThrowMSLException(OptionError,"NoImagesDefined",
4230 (const char *) tag);
4233 (void) QueryMagickColor("none",&target,&exception);
4234 (void) QueryMagickColor("none",&fill_color,&exception);
4235 if (attributes != (const xmlChar **) NULL)
4236 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4238 keyword=(const char *) attributes[i++];
4239 attribute=InterpretImageProperties(msl_info->image_info[n],
4240 msl_info->attributes[n],(const char *) attributes[i],
4242 CloneString(&value,attribute);
4248 if (LocaleCompare(keyword,"channel") == 0)
4250 option=ParseChannelOption(value);
4252 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4254 channel=(ChannelType) option;
4257 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4264 if (LocaleCompare(keyword,"fill") == 0)
4266 (void) QueryMagickColor(value,&fill_color,&exception);
4269 if (LocaleCompare(keyword,"fuzz") == 0)
4271 msl_info->image[n]->fuzz=InterpretLocaleValue(value,
4275 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4281 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4287 channel_mask=SetPixelChannelMask(msl_info->image[n],channel);
4288 (void) OpaquePaintImage(msl_info->image[n],&target,&fill_color,
4289 MagickFalse,&msl_info->image[n]->exception);
4290 (void) SetPixelChannelMap(msl_info->image[n],channel_mask);
4293 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4298 if (LocaleCompare((const char *) tag,"print") == 0)
4300 if (attributes == (const xmlChar **) NULL)
4302 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4304 keyword=(const char *) attributes[i++];
4305 attribute=InterpretImageProperties(msl_info->image_info[n],
4306 msl_info->attributes[n],(const char *) attributes[i],
4308 CloneString(&value,attribute);
4314 if (LocaleCompare(keyword,"output") == 0)
4316 (void) FormatLocaleFile(stdout,"%s",value);
4319 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4324 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4331 if (LocaleCompare((const char *) tag, "profile") == 0)
4333 if (msl_info->image[n] == (Image *) NULL)
4335 ThrowMSLException(OptionError,"NoImagesDefined",
4336 (const char *) tag);
4339 if (attributes == (const xmlChar **) NULL)
4341 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4355 keyword=(const char *) attributes[i++];
4356 attribute=InterpretImageProperties(msl_info->image_info[n],
4357 msl_info->attributes[n],(const char *) attributes[i],
4359 CloneString(&value,attribute);
4360 if (*keyword == '+')
4363 Remove a profile from the image.
4365 (void) ProfileImage(msl_info->image[n],keyword,
4366 (const unsigned char *) NULL,0,MagickTrue);
4370 Associate a profile with the image.
4372 profile_info=CloneImageInfo(msl_info->image_info[n]);
4373 profile=GetImageProfile(msl_info->image[n],"iptc");
4374 if (profile != (StringInfo *) NULL)
4375 profile_info->profile=(void *) CloneStringInfo(profile);
4376 profile_image=GetImageCache(profile_info,keyword,&exception);
4377 profile_info=DestroyImageInfo(profile_info);
4378 if (profile_image == (Image *) NULL)
4381 name[MaxTextExtent],
4382 filename[MaxTextExtent];
4390 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4391 (void) CopyMagickString(name,keyword,MaxTextExtent);
4392 for (p=filename; *p != '\0'; p++)
4393 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4394 (IsPathAccessible(keyword) == MagickFalse))
4400 Look for profile name (e.g. name:profile).
4402 (void) CopyMagickString(name,filename,(size_t)
4404 for (q=filename; *q != '\0'; q++)
4408 profile=FileToStringInfo(filename,~0UL,&exception);
4409 if (profile != (StringInfo *) NULL)
4411 (void) ProfileImage(msl_info->image[n],name,
4412 GetStringInfoDatum(profile),(size_t)
4413 GetStringInfoLength(profile),MagickFalse);
4414 profile=DestroyStringInfo(profile);
4418 ResetImageProfileIterator(profile_image);
4419 name=GetNextImageProfile(profile_image);
4420 while (name != (const char *) NULL)
4422 profile=GetImageProfile(profile_image,name);
4423 if (profile != (StringInfo *) NULL)
4424 (void) ProfileImage(msl_info->image[n],name,
4425 GetStringInfoDatum(profile),(size_t)
4426 GetStringInfoLength(profile),MagickFalse);
4427 name=GetNextImageProfile(profile_image);
4429 profile_image=DestroyImage(profile_image);
4433 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4438 if (LocaleCompare((const char *) tag,"quantize") == 0)
4446 if (msl_info->image[n] == (Image *) NULL)
4448 ThrowMSLException(OptionError,"NoImagesDefined",
4449 (const char *) tag);
4452 GetQuantizeInfo(&quantize_info);
4453 if (attributes != (const xmlChar **) NULL)
4454 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4456 keyword=(const char *) attributes[i++];
4457 attribute=InterpretImageProperties(msl_info->image_info[n],
4458 msl_info->attributes[n],(const char *) attributes[i],
4460 CloneString(&value,attribute);
4466 if (LocaleCompare(keyword,"colors") == 0)
4468 quantize_info.number_colors=StringToLong(value);
4471 if (LocaleCompare(keyword,"colorspace") == 0)
4473 option=ParseCommandOption(MagickColorspaceOptions,
4476 ThrowMSLException(OptionError,
4477 "UnrecognizedColorspaceType",value);
4478 quantize_info.colorspace=(ColorspaceType) option;
4481 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4488 if (LocaleCompare(keyword,"dither") == 0)
4490 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4493 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4495 quantize_info.dither=(MagickBooleanType) option;
4498 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4505 if (LocaleCompare(keyword,"measure") == 0)
4507 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4510 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4512 quantize_info.measure_error=(MagickBooleanType) option;
4515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4522 if (LocaleCompare(keyword,"treedepth") == 0)
4524 quantize_info.tree_depth=StringToLong(value);
4527 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4533 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4539 (void) QuantizeImage(&quantize_info,msl_info->image[n],&exception);
4542 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4545 text[MaxTextExtent];
4556 draw_info=CloneDrawInfo(msl_info->image_info[n],
4557 msl_info->draw_info[n]);
4559 current=draw_info->affine;
4560 GetAffineMatrix(&affine);
4561 if (attributes != (const xmlChar **) NULL)
4562 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4564 keyword=(const char *) attributes[i++];
4565 attribute=InterpretImageProperties(msl_info->image_info[n],
4566 msl_info->attributes[n],(const char *) attributes[i],
4568 CloneString(&value,attribute);
4574 if (LocaleCompare(keyword,"affine") == 0)
4580 draw_info->affine.sx=InterpretLocaleValue(p,&p);
4583 draw_info->affine.rx=InterpretLocaleValue(p,&p);
4586 draw_info->affine.ry=InterpretLocaleValue(p,&p);
4589 draw_info->affine.sy=InterpretLocaleValue(p,&p);
4592 draw_info->affine.tx=InterpretLocaleValue(p,&p);
4595 draw_info->affine.ty=InterpretLocaleValue(p,&p);
4598 if (LocaleCompare(keyword,"align") == 0)
4600 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4603 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4605 draw_info->align=(AlignType) option;
4608 if (LocaleCompare(keyword,"antialias") == 0)
4610 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4613 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4615 draw_info->stroke_antialias=(MagickBooleanType) option;
4616 draw_info->text_antialias=(MagickBooleanType) option;
4619 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4626 if (LocaleCompare(keyword,"density") == 0)
4628 CloneString(&draw_info->density,value);
4631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(keyword,"encoding") == 0)
4640 CloneString(&draw_info->encoding,value);
4643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4650 if (LocaleCompare(keyword, "fill") == 0)
4652 (void) QueryColorDatabase(value,&draw_info->fill,
4656 if (LocaleCompare(keyword,"family") == 0)
4658 CloneString(&draw_info->family,value);
4661 if (LocaleCompare(keyword,"font") == 0)
4663 CloneString(&draw_info->font,value);
4666 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4673 if (LocaleCompare(keyword,"geometry") == 0)
4675 flags=ParsePageGeometry(msl_info->image[n],value,
4676 &geometry,&exception);
4677 if ((flags & HeightValue) == 0)
4678 geometry.height=geometry.width;
4681 if (LocaleCompare(keyword,"gravity") == 0)
4683 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4686 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4688 draw_info->gravity=(GravityType) option;
4691 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4698 if (LocaleCompare(keyword,"pointsize") == 0)
4700 draw_info->pointsize=InterpretLocaleValue(value,
4704 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4711 if (LocaleCompare(keyword,"rotate") == 0)
4713 angle=InterpretLocaleValue(value,(char **) NULL);
4714 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4715 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4716 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4717 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4720 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4727 if (LocaleCompare(keyword,"scale") == 0)
4729 flags=ParseGeometry(value,&geometry_info);
4730 if ((flags & SigmaValue) == 0)
4731 geometry_info.sigma=1.0;
4732 affine.sx=geometry_info.rho;
4733 affine.sy=geometry_info.sigma;
4736 if (LocaleCompare(keyword,"skewX") == 0)
4738 angle=InterpretLocaleValue(value,(char **) NULL);
4739 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4742 if (LocaleCompare(keyword,"skewY") == 0)
4744 angle=InterpretLocaleValue(value,(char **) NULL);
4745 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4748 if (LocaleCompare(keyword,"stretch") == 0)
4750 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4753 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4755 draw_info->stretch=(StretchType) option;
4758 if (LocaleCompare(keyword, "stroke") == 0)
4760 (void) QueryColorDatabase(value,&draw_info->stroke,
4764 if (LocaleCompare(keyword,"strokewidth") == 0)
4766 draw_info->stroke_width=StringToLong(value);
4769 if (LocaleCompare(keyword,"style") == 0)
4771 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4774 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4776 draw_info->style=(StyleType) option;
4779 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4786 if (LocaleCompare(keyword,"text") == 0)
4788 CloneString(&draw_info->text,value);
4791 if (LocaleCompare(keyword,"translate") == 0)
4793 flags=ParseGeometry(value,&geometry_info);
4794 if ((flags & SigmaValue) == 0)
4795 geometry_info.sigma=1.0;
4796 affine.tx=geometry_info.rho;
4797 affine.ty=geometry_info.sigma;
4800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4807 if (LocaleCompare(keyword, "undercolor") == 0)
4809 (void) QueryColorDatabase(value,&draw_info->undercolor,
4813 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4820 if (LocaleCompare(keyword,"weight") == 0)
4822 draw_info->weight=StringToLong(value);
4825 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4832 if (LocaleCompare(keyword,"x") == 0)
4834 geometry.x=StringToLong(value);
4837 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4844 if (LocaleCompare(keyword,"y") == 0)
4846 geometry.y=StringToLong(value);
4849 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4855 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4861 (void) FormatLocaleString(text,MaxTextExtent,
4862 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4863 geometry.height,(double) geometry.x,(double) geometry.y);
4864 CloneString(&draw_info->geometry,text);
4865 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4866 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4867 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4868 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4869 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4871 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4873 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics,
4874 &msl_info->image[n]->exception);
4875 if (status != MagickFalse)
4880 image=msl_info->attributes[n];
4881 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4882 "%g",metrics.pixels_per_em.x);
4883 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4884 "%g",metrics.pixels_per_em.y);
4885 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4887 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4889 FormatImageProperty(image,"msl:font-metrics.width","%g",
4891 FormatImageProperty(image,"msl:font-metrics.height","%g",
4893 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4894 metrics.max_advance);
4895 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4897 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4899 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4901 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4903 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4905 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4908 draw_info=DestroyDrawInfo(draw_info);
4911 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4916 if (LocaleCompare((const char *) tag,"raise") == 0)
4924 if (msl_info->image[n] == (Image *) NULL)
4926 ThrowMSLException(OptionError,"NoImagesDefined",
4927 (const char *) tag);
4931 SetGeometry(msl_info->image[n],&geometry);
4932 if (attributes != (const xmlChar **) NULL)
4933 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4935 keyword=(const char *) attributes[i++];
4936 attribute=InterpretImageProperties(msl_info->image_info[n],
4937 msl_info->attributes[n],(const char *) attributes[i],
4939 CloneString(&value,attribute);
4945 if (LocaleCompare(keyword,"geometry") == 0)
4947 flags=ParsePageGeometry(msl_info->image[n],value,
4948 &geometry,&exception);
4949 if ((flags & HeightValue) == 0)
4950 geometry.height=geometry.width;
4953 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4960 if (LocaleCompare(keyword,"height") == 0)
4962 geometry.height=StringToLong(value);
4965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4972 if (LocaleCompare(keyword,"raise") == 0)
4974 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4977 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4979 raise=(MagickBooleanType) option;
4982 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4989 if (LocaleCompare(keyword,"width") == 0)
4991 geometry.width=StringToLong(value);
4994 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5000 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5006 (void) RaiseImage(msl_info->image[n],&geometry,raise,
5007 &msl_info->image[n]->exception);
5010 if (LocaleCompare((const char *) tag,"read") == 0)
5012 if (attributes == (const xmlChar **) NULL)
5014 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5016 keyword=(const char *) attributes[i++];
5017 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5018 msl_info->attributes[n],(const char *) attributes[i],&exception));
5024 if (LocaleCompare(keyword,"filename") == 0)
5029 (void) CopyMagickString(msl_info->image_info[n]->filename,
5030 value,MaxTextExtent);
5031 image=ReadImage(msl_info->image_info[n],&exception);
5032 CatchException(&exception);
5033 if (image == (Image *) NULL)
5035 AppendImageToList(&msl_info->image[n],image);
5038 (void) SetMSLAttributes(msl_info,keyword,value);
5043 (void) SetMSLAttributes(msl_info,keyword,value);
5050 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
5058 if (msl_info->image[n] == (Image *) NULL)
5060 ThrowMSLException(OptionError,"NoImagesDefined",
5061 (const char *) tag);
5064 if (attributes != (const xmlChar **) NULL)
5065 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5067 keyword=(const char *) attributes[i++];
5068 attribute=InterpretImageProperties(msl_info->image_info[n],
5069 msl_info->attributes[n],(const char *) attributes[i],
5071 CloneString(&value,attribute);
5077 if (LocaleCompare(keyword,"geometry") == 0)
5079 flags=ParseGeometry(value,&geometry_info);
5080 if ((flags & SigmaValue) == 0)
5081 geometry_info.sigma=1.0;
5084 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5091 if (LocaleCompare(keyword,"radius") == 0)
5093 geometry_info.rho=InterpretLocaleValue(value,
5097 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5103 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5109 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5110 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5111 &msl_info->image[n]->exception);
5112 if (paint_image == (Image *) NULL)
5114 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5115 msl_info->image[n]=paint_image;
5118 else if (LocaleCompare((const char *) tag,"repage") == 0)
5120 /* init the values */
5121 width=msl_info->image[n]->page.width;
5122 height=msl_info->image[n]->page.height;
5123 x=msl_info->image[n]->page.x;
5124 y=msl_info->image[n]->page.y;
5126 if (msl_info->image[n] == (Image *) NULL)
5128 ThrowMSLException(OptionError,"NoImagesDefined",
5129 (const char *) tag);
5132 if (attributes == (const xmlChar **) NULL)
5134 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5136 keyword=(const char *) attributes[i++];
5137 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5138 msl_info->attributes[n],(const char *) attributes[i],&exception));
5144 if (LocaleCompare(keyword,"geometry") == 0)
5152 flags=ParseAbsoluteGeometry(value,&geometry);
5153 if ((flags & WidthValue) != 0)
5155 if ((flags & HeightValue) == 0)
5156 geometry.height=geometry.width;
5157 width=geometry.width;
5158 height=geometry.height;
5160 if ((flags & AspectValue) != 0)
5162 if ((flags & XValue) != 0)
5164 if ((flags & YValue) != 0)
5169 if ((flags & XValue) != 0)
5172 if ((width == 0) && (geometry.x > 0))
5173 width=msl_info->image[n]->columns+geometry.x;
5175 if ((flags & YValue) != 0)
5178 if ((height == 0) && (geometry.y > 0))
5179 height=msl_info->image[n]->rows+geometry.y;
5184 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5190 if (LocaleCompare(keyword,"height") == 0)
5192 height = StringToLong( value );
5195 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5201 if (LocaleCompare(keyword,"width") == 0)
5203 width = StringToLong( value );
5206 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5212 if (LocaleCompare(keyword,"x") == 0)
5214 x = StringToLong( value );
5217 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5223 if (LocaleCompare(keyword,"y") == 0)
5225 y = StringToLong( value );
5228 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5233 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5239 msl_info->image[n]->page.width=width;
5240 msl_info->image[n]->page.height=height;
5241 msl_info->image[n]->page.x=x;
5242 msl_info->image[n]->page.y=y;
5245 else if (LocaleCompare((const char *) tag,"resample") == 0)
5251 if (msl_info->image[n] == (Image *) NULL)
5253 ThrowMSLException(OptionError,"NoImagesDefined",
5254 (const char *) tag);
5257 if (attributes == (const xmlChar **) NULL)
5259 x_resolution=DefaultResolution;
5260 y_resolution=DefaultResolution;
5261 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5263 keyword=(const char *) attributes[i++];
5264 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5265 msl_info->attributes[n],(const char *) attributes[i],&exception));
5270 if (LocaleCompare(keyword,"blur") == 0)
5272 msl_info->image[n]->blur=InterpretLocaleValue(value,
5276 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5282 if (LocaleCompare(keyword,"geometry") == 0)
5287 flags=ParseGeometry(value,&geometry_info);
5288 if ((flags & SigmaValue) == 0)
5289 geometry_info.sigma*=geometry_info.rho;
5290 x_resolution=geometry_info.rho;
5291 y_resolution=geometry_info.sigma;
5294 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5300 if (LocaleCompare(keyword,"x-resolution") == 0)
5302 x_resolution=InterpretLocaleValue(value,(char **) NULL);
5305 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5311 if (LocaleCompare(keyword,"y-resolution") == 0)
5313 y_resolution=InterpretLocaleValue(value,(char **) NULL);
5316 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5321 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5337 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5339 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5340 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5341 msl_info->image[n]->x_resolution))+0.5);
5342 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5343 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5344 msl_info->image[n]->y_resolution))+0.5);
5345 resample_image=ResizeImage(msl_info->image[n],width,height,
5346 msl_info->image[n]->filter,msl_info->image[n]->blur,
5347 &msl_info->image[n]->exception);
5348 if (resample_image == (Image *) NULL)
5350 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5351 msl_info->image[n]=resample_image;
5355 if (LocaleCompare((const char *) tag,"resize") == 0)
5369 if (msl_info->image[n] == (Image *) NULL)
5371 ThrowMSLException(OptionError,"NoImagesDefined",
5372 (const char *) tag);
5375 filter=UndefinedFilter;
5377 if (attributes != (const xmlChar **) NULL)
5378 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5380 keyword=(const char *) attributes[i++];
5381 attribute=InterpretImageProperties(msl_info->image_info[n],
5382 msl_info->attributes[n],(const char *) attributes[i],
5384 CloneString(&value,attribute);
5390 if (LocaleCompare(keyword,"filter") == 0)
5392 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5395 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5397 filter=(FilterTypes) option;
5400 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5407 if (LocaleCompare(keyword,"geometry") == 0)
5409 flags=ParseRegionGeometry(msl_info->image[n],value,
5410 &geometry,&exception);
5413 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5420 if (LocaleCompare(keyword,"height") == 0)
5422 geometry.height=StringToUnsignedLong(value);
5425 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5432 if (LocaleCompare(keyword,"support") == 0)
5434 blur=InterpretLocaleValue(value,(char **) NULL);
5437 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5444 if (LocaleCompare(keyword,"width") == 0)
5446 geometry.width=StringToLong(value);
5449 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5455 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5461 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5462 geometry.height,filter,blur,&msl_info->image[n]->exception);
5463 if (resize_image == (Image *) NULL)
5465 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5466 msl_info->image[n]=resize_image;
5469 if (LocaleCompare((const char *) tag,"roll") == 0)
5477 if (msl_info->image[n] == (Image *) NULL)
5479 ThrowMSLException(OptionError,"NoImagesDefined",
5480 (const char *) tag);
5483 SetGeometry(msl_info->image[n],&geometry);
5484 if (attributes != (const xmlChar **) NULL)
5485 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5487 keyword=(const char *) attributes[i++];
5488 attribute=InterpretImageProperties(msl_info->image_info[n],
5489 msl_info->attributes[n],(const char *) attributes[i],
5491 CloneString(&value,attribute);
5497 if (LocaleCompare(keyword,"geometry") == 0)
5499 flags=ParsePageGeometry(msl_info->image[n],value,
5500 &geometry,&exception);
5501 if ((flags & HeightValue) == 0)
5502 geometry.height=geometry.width;
5505 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5512 if (LocaleCompare(keyword,"x") == 0)
5514 geometry.x=StringToLong(value);
5517 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5524 if (LocaleCompare(keyword,"y") == 0)
5526 geometry.y=StringToLong(value);
5529 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5535 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5541 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5542 &msl_info->image[n]->exception);
5543 if (roll_image == (Image *) NULL)
5545 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5546 msl_info->image[n]=roll_image;
5549 else if (LocaleCompare((const char *) tag,"roll") == 0)
5551 /* init the values */
5552 width=msl_info->image[n]->columns;
5553 height=msl_info->image[n]->rows;
5556 if (msl_info->image[n] == (Image *) NULL)
5558 ThrowMSLException(OptionError,"NoImagesDefined",
5559 (const char *) tag);
5562 if (attributes == (const xmlChar **) NULL)
5564 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5566 keyword=(const char *) attributes[i++];
5567 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5568 msl_info->attributes[n],(const char *) attributes[i],&exception));
5574 if (LocaleCompare(keyword,"geometry") == 0)
5576 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5579 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5585 if (LocaleCompare(keyword,"x") == 0)
5587 x = StringToLong( value );
5590 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5596 if (LocaleCompare(keyword,"y") == 0)
5598 y = StringToLong( value );
5601 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5606 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5619 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5620 if (newImage == (Image *) NULL)
5622 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5623 msl_info->image[n]=newImage;
5628 if (LocaleCompare((const char *) tag,"rotate") == 0)
5636 if (msl_info->image[n] == (Image *) NULL)
5638 ThrowMSLException(OptionError,"NoImagesDefined",
5639 (const char *) tag);
5642 if (attributes != (const xmlChar **) NULL)
5643 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5645 keyword=(const char *) attributes[i++];
5646 attribute=InterpretImageProperties(msl_info->image_info[n],
5647 msl_info->attributes[n],(const char *) attributes[i],
5649 CloneString(&value,attribute);
5655 if (LocaleCompare(keyword,"degrees") == 0)
5657 geometry_info.rho=InterpretLocaleValue(value,
5661 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5668 if (LocaleCompare(keyword,"geometry") == 0)
5670 flags=ParseGeometry(value,&geometry_info);
5671 if ((flags & SigmaValue) == 0)
5672 geometry_info.sigma=1.0;
5675 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5681 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5687 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5688 &msl_info->image[n]->exception);
5689 if (rotate_image == (Image *) NULL)
5691 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5692 msl_info->image[n]=rotate_image;
5695 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5697 /* init the values */
5700 if (msl_info->image[n] == (Image *) NULL)
5702 ThrowMSLException(OptionError,"NoImagesDefined",
5703 (const char *) tag);
5706 if (attributes == (const xmlChar **) NULL)
5708 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5710 keyword=(const char *) attributes[i++];
5711 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5712 msl_info->attributes[n],(const char *) attributes[i],&exception));
5718 if (LocaleCompare(keyword,"degrees") == 0)
5720 degrees = InterpretLocaleValue(value,(char **) NULL);
5723 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5728 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5741 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5742 if (newImage == (Image *) NULL)
5744 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5745 msl_info->image[n]=newImage;
5750 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5755 if (LocaleCompare((const char *) tag,"sample") == 0)
5763 if (msl_info->image[n] == (Image *) NULL)
5765 ThrowMSLException(OptionError,"NoImagesDefined",
5766 (const char *) tag);
5769 if (attributes != (const xmlChar **) NULL)
5770 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5772 keyword=(const char *) attributes[i++];
5773 attribute=InterpretImageProperties(msl_info->image_info[n],
5774 msl_info->attributes[n],(const char *) attributes[i],
5776 CloneString(&value,attribute);
5782 if (LocaleCompare(keyword,"geometry") == 0)
5784 flags=ParseRegionGeometry(msl_info->image[n],value,
5785 &geometry,&exception);
5788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5795 if (LocaleCompare(keyword,"height") == 0)
5797 geometry.height=StringToUnsignedLong(value);
5800 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5807 if (LocaleCompare(keyword,"width") == 0)
5809 geometry.width=StringToLong(value);
5812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5818 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5824 sample_image=SampleImage(msl_info->image[n],geometry.width,
5825 geometry.height,&msl_info->image[n]->exception);
5826 if (sample_image == (Image *) NULL)
5828 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5829 msl_info->image[n]=sample_image;
5832 if (LocaleCompare((const char *) tag,"scale") == 0)
5840 if (msl_info->image[n] == (Image *) NULL)
5842 ThrowMSLException(OptionError,"NoImagesDefined",
5843 (const char *) tag);
5846 if (attributes != (const xmlChar **) NULL)
5847 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5849 keyword=(const char *) attributes[i++];
5850 attribute=InterpretImageProperties(msl_info->image_info[n],
5851 msl_info->attributes[n],(const char *) attributes[i],
5853 CloneString(&value,attribute);
5859 if (LocaleCompare(keyword,"geometry") == 0)
5861 flags=ParseRegionGeometry(msl_info->image[n],value,
5862 &geometry,&exception);
5865 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5872 if (LocaleCompare(keyword,"height") == 0)
5874 geometry.height=StringToUnsignedLong(value);
5877 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5884 if (LocaleCompare(keyword,"width") == 0)
5886 geometry.width=StringToLong(value);
5889 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5895 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5901 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5902 geometry.height,&msl_info->image[n]->exception);
5903 if (scale_image == (Image *) NULL)
5905 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5906 msl_info->image[n]=scale_image;
5909 if (LocaleCompare((const char *) tag,"segment") == 0)
5920 if (msl_info->image[n] == (Image *) NULL)
5922 ThrowMSLException(OptionError,"NoImagesDefined",
5923 (const char *) tag);
5926 geometry_info.rho=1.0;
5927 geometry_info.sigma=1.5;
5928 colorspace=RGBColorspace;
5929 verbose=MagickFalse;
5930 if (attributes != (const xmlChar **) NULL)
5931 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5933 keyword=(const char *) attributes[i++];
5934 attribute=InterpretImageProperties(msl_info->image_info[n],
5935 msl_info->attributes[n],(const char *) attributes[i],
5937 CloneString(&value,attribute);
5943 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5945 geometry_info.rho=InterpretLocaleValue(value,
5949 if (LocaleCompare(keyword,"colorspace") == 0)
5951 option=ParseCommandOption(MagickColorspaceOptions,
5954 ThrowMSLException(OptionError,
5955 "UnrecognizedColorspaceType",value);
5956 colorspace=(ColorspaceType) option;
5959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5966 if (LocaleCompare(keyword,"geometry") == 0)
5968 flags=ParseGeometry(value,&geometry_info);
5969 if ((flags & SigmaValue) == 0)
5970 geometry_info.sigma=1.5;
5973 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5980 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5982 geometry_info.sigma=InterpretLocaleValue(value,
5986 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5992 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5998 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5999 geometry_info.rho,geometry_info.sigma,&exception);
6002 else if (LocaleCompare((const char *) tag, "set") == 0)
6004 if (msl_info->image[n] == (Image *) NULL)
6006 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6010 if (attributes == (const xmlChar **) NULL)
6012 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6014 keyword=(const char *) attributes[i++];
6015 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6016 msl_info->attributes[n],(const char *) attributes[i],&exception));
6022 if (LocaleCompare(keyword,"clip-mask") == 0)
6024 for (j=0; j < msl_info->n; j++)
6029 property=GetImageProperty(msl_info->attributes[j],"id");
6030 if (LocaleCompare(property,value) == 0)
6032 SetImageMask(msl_info->image[n],msl_info->image[j],
6039 if (LocaleCompare(keyword,"clip-path") == 0)
6041 for (j=0; j < msl_info->n; j++)
6046 property=GetImageProperty(msl_info->attributes[j],"id");
6047 if (LocaleCompare(property,value) == 0)
6049 SetImageClipMask(msl_info->image[n],msl_info->image[j],
6056 if (LocaleCompare(keyword,"colorspace") == 0)
6061 colorspace=(ColorspaceType) ParseCommandOption(
6062 MagickColorspaceOptions,MagickFalse,value);
6064 ThrowMSLException(OptionError,"UnrecognizedColorspace",
6066 (void) TransformImageColorspace(msl_info->image[n],
6067 (ColorspaceType) colorspace);
6070 (void) SetMSLAttributes(msl_info,keyword,value);
6071 (void) SetImageProperty(msl_info->image[n],keyword,value);
6077 if (LocaleCompare(keyword,"density") == 0)
6079 flags=ParseGeometry(value,&geometry_info);
6080 msl_info->image[n]->x_resolution=geometry_info.rho;
6081 msl_info->image[n]->y_resolution=geometry_info.sigma;
6082 if ((flags & SigmaValue) == 0)
6083 msl_info->image[n]->y_resolution=
6084 msl_info->image[n]->x_resolution;
6087 (void) SetMSLAttributes(msl_info,keyword,value);
6088 (void) SetImageProperty(msl_info->image[n],keyword,value);
6094 if (LocaleCompare(keyword, "opacity") == 0)
6096 ssize_t opac = OpaqueAlpha,
6097 len = (ssize_t) strlen( value );
6099 if (value[len-1] == '%') {
6101 (void) CopyMagickString(tmp,value,len);
6102 opac = StringToLong( tmp );
6103 opac = (int)(QuantumRange * ((float)opac/100));
6105 opac = StringToLong( value );
6106 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6109 (void) SetMSLAttributes(msl_info,keyword,value);
6110 (void) SetImageProperty(msl_info->image[n],keyword,value);
6116 if (LocaleCompare(keyword, "page") == 0)
6119 page[MaxTextExtent];
6130 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6131 image_option=GetImageOption(msl_info->image_info[n],"page");
6132 if (image_option != (const char *) NULL)
6133 flags=ParseAbsoluteGeometry(image_option,&geometry);
6134 flags=ParseAbsoluteGeometry(value,&geometry);
6135 (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g",
6136 (double) geometry.width,(double) geometry.height);
6137 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6138 (void) FormatLocaleString(page,MaxTextExtent,
6139 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6140 (double) geometry.height,(double) geometry.x,(double)
6142 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6143 msl_info->image_info[n]->page=GetPageGeometry(page);
6146 (void) SetMSLAttributes(msl_info,keyword,value);
6147 (void) SetImageProperty(msl_info->image[n],keyword,value);
6152 (void) SetMSLAttributes(msl_info,keyword,value);
6153 (void) SetImageProperty(msl_info->image[n],keyword,value);
6160 if (LocaleCompare((const char *) tag,"shade") == 0)
6171 if (msl_info->image[n] == (Image *) NULL)
6173 ThrowMSLException(OptionError,"NoImagesDefined",
6174 (const char *) tag);
6178 if (attributes != (const xmlChar **) NULL)
6179 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6181 keyword=(const char *) attributes[i++];
6182 attribute=InterpretImageProperties(msl_info->image_info[n],
6183 msl_info->attributes[n],(const char *) attributes[i],
6185 CloneString(&value,attribute);
6191 if (LocaleCompare(keyword,"azimuth") == 0)
6193 geometry_info.rho=InterpretLocaleValue(value,
6197 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6204 if (LocaleCompare(keyword,"elevation") == 0)
6206 geometry_info.sigma=InterpretLocaleValue(value,
6210 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6217 if (LocaleCompare(keyword,"geometry") == 0)
6219 flags=ParseGeometry(value,&geometry_info);
6220 if ((flags & SigmaValue) == 0)
6221 geometry_info.sigma=1.0;
6224 if (LocaleCompare(keyword,"gray") == 0)
6226 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6229 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6231 gray=(MagickBooleanType) option;
6234 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6240 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6246 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6247 geometry_info.sigma,&msl_info->image[n]->exception);
6248 if (shade_image == (Image *) NULL)
6250 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6251 msl_info->image[n]=shade_image;
6254 if (LocaleCompare((const char *) tag,"shadow") == 0)
6262 if (msl_info->image[n] == (Image *) NULL)
6264 ThrowMSLException(OptionError,"NoImagesDefined",
6265 (const char *) tag);
6268 if (attributes != (const xmlChar **) NULL)
6269 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6271 keyword=(const char *) attributes[i++];
6272 attribute=InterpretImageProperties(msl_info->image_info[n],
6273 msl_info->attributes[n],(const char *) attributes[i],
6275 CloneString(&value,attribute);
6281 if (LocaleCompare(keyword,"geometry") == 0)
6283 flags=ParseGeometry(value,&geometry_info);
6284 if ((flags & SigmaValue) == 0)
6285 geometry_info.sigma=1.0;
6288 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6295 if (LocaleCompare(keyword,"opacity") == 0)
6297 geometry_info.rho=StringToLong(value);
6300 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6307 if (LocaleCompare(keyword,"sigma") == 0)
6309 geometry_info.sigma=StringToLong(value);
6317 if (LocaleCompare(keyword,"x") == 0)
6319 geometry_info.xi=InterpretLocaleValue(value,
6323 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6330 if (LocaleCompare(keyword,"y") == 0)
6332 geometry_info.psi=StringToLong(value);
6335 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6341 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6347 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6348 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6349 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6350 if (shadow_image == (Image *) NULL)
6352 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6353 msl_info->image[n]=shadow_image;
6356 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6362 if (msl_info->image[n] == (Image *) NULL)
6364 ThrowMSLException(OptionError,"NoImagesDefined",
6365 (const char *) tag);
6369 NOTE: sharpen can have no attributes, since we use all the defaults!
6371 if (attributes != (const xmlChar **) NULL)
6373 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6375 keyword=(const char *) attributes[i++];
6376 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6377 msl_info->attributes[n],(const char *) attributes[i],&exception));
6383 if (LocaleCompare(keyword, "bias") == 0)
6385 bias = InterpretLocaleValue(value,(char **) NULL);
6388 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6394 if (LocaleCompare(keyword, "radius") == 0)
6396 radius = InterpretLocaleValue(value,(char **) NULL);
6399 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6405 if (LocaleCompare(keyword,"sigma") == 0)
6407 sigma = StringToLong( value );
6410 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6415 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6429 newImage=SharpenImage(msl_info->image[n],radius,sigma,bias,
6430 &msl_info->image[n]->exception);
6431 if (newImage == (Image *) NULL)
6433 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6434 msl_info->image[n]=newImage;
6438 else if (LocaleCompare((const char *) tag,"shave") == 0)
6440 /* init the values */
6444 if (msl_info->image[n] == (Image *) NULL)
6446 ThrowMSLException(OptionError,"NoImagesDefined",
6447 (const char *) tag);
6450 if (attributes == (const xmlChar **) NULL)
6452 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6454 keyword=(const char *) attributes[i++];
6455 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6456 msl_info->attributes[n],(const char *) attributes[i],&exception));
6462 if (LocaleCompare(keyword,"geometry") == 0)
6464 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6467 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6473 if (LocaleCompare(keyword,"height") == 0)
6475 height = StringToLong( value );
6478 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6484 if (LocaleCompare(keyword,"width") == 0)
6486 width = StringToLong( value );
6489 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6494 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6509 rectInfo.height = height;
6510 rectInfo.width = width;
6515 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6516 &msl_info->image[n]->exception);
6517 if (newImage == (Image *) NULL)
6519 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6520 msl_info->image[n]=newImage;
6525 if (LocaleCompare((const char *) tag,"shear") == 0)
6533 if (msl_info->image[n] == (Image *) NULL)
6535 ThrowMSLException(OptionError,"NoImagesDefined",
6536 (const char *) tag);
6539 if (attributes != (const xmlChar **) NULL)
6540 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6542 keyword=(const char *) attributes[i++];
6543 attribute=InterpretImageProperties(msl_info->image_info[n],
6544 msl_info->attributes[n],(const char *) attributes[i],
6546 CloneString(&value,attribute);
6552 if (LocaleCompare(keyword, "fill") == 0)
6554 (void) QueryColorDatabase(value,
6555 &msl_info->image[n]->background_color,&exception);
6558 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6565 if (LocaleCompare(keyword,"geometry") == 0)
6567 flags=ParseGeometry(value,&geometry_info);
6568 if ((flags & SigmaValue) == 0)
6569 geometry_info.sigma=1.0;
6572 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6579 if (LocaleCompare(keyword,"x") == 0)
6581 geometry_info.rho=InterpretLocaleValue(value,
6585 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6592 if (LocaleCompare(keyword,"y") == 0)
6594 geometry_info.sigma=StringToLong(value);
6597 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6603 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6609 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6610 geometry_info.sigma,&msl_info->image[n]->exception);
6611 if (shear_image == (Image *) NULL)
6613 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6614 msl_info->image[n]=shear_image;
6617 if (LocaleCompare((const char *) tag,"signature") == 0)
6622 if (msl_info->image[n] == (Image *) NULL)
6624 ThrowMSLException(OptionError,"NoImagesDefined",
6625 (const char *) tag);
6628 if (attributes != (const xmlChar **) NULL)
6629 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6631 keyword=(const char *) attributes[i++];
6632 attribute=InterpretImageProperties(msl_info->image_info[n],
6633 msl_info->attributes[n],(const char *) attributes[i],
6635 CloneString(&value,attribute);
6640 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6646 (void) SignatureImage(msl_info->image[n],&exception);
6649 if (LocaleCompare((const char *) tag,"solarize") == 0)
6654 if (msl_info->image[n] == (Image *) NULL)
6656 ThrowMSLException(OptionError,"NoImagesDefined",
6657 (const char *) tag);
6660 geometry_info.rho=QuantumRange/2.0;
6661 if (attributes != (const xmlChar **) NULL)
6662 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6664 keyword=(const char *) attributes[i++];
6665 attribute=InterpretImageProperties(msl_info->image_info[n],
6666 msl_info->attributes[n],(const char *) attributes[i],
6668 CloneString(&value,attribute);
6674 if (LocaleCompare(keyword,"geometry") == 0)
6676 flags=ParseGeometry(value,&geometry_info);
6679 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6686 if (LocaleCompare(keyword,"threshold") == 0)
6688 geometry_info.rho=InterpretLocaleValue(value,
6692 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6698 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6704 (void) SolarizeImage(msl_info->image[n],geometry_info.rho,
6705 &msl_info->image[n]->exception);
6708 if (LocaleCompare((const char *) tag,"spread") == 0)
6716 if (msl_info->image[n] == (Image *) NULL)
6718 ThrowMSLException(OptionError,"NoImagesDefined",
6719 (const char *) tag);
6722 if (attributes != (const xmlChar **) NULL)
6723 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6725 keyword=(const char *) attributes[i++];
6726 attribute=InterpretImageProperties(msl_info->image_info[n],
6727 msl_info->attributes[n],(const char *) attributes[i],
6729 CloneString(&value,attribute);
6735 if (LocaleCompare(keyword,"geometry") == 0)
6737 flags=ParseGeometry(value,&geometry_info);
6738 if ((flags & SigmaValue) == 0)
6739 geometry_info.sigma=1.0;
6742 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6749 if (LocaleCompare(keyword,"radius") == 0)
6751 geometry_info.rho=InterpretLocaleValue(value,
6755 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6761 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6767 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6768 &msl_info->image[n]->exception);
6769 if (spread_image == (Image *) NULL)
6771 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6772 msl_info->image[n]=spread_image;
6775 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6778 watermark = (Image*)NULL;
6780 if (msl_info->image[n] == (Image *) NULL)
6782 ThrowMSLException(OptionError,"NoImagesDefined",
6783 (const char *) tag);
6786 if (attributes == (const xmlChar **) NULL)
6788 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6790 keyword=(const char *) attributes[i++];
6791 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6792 msl_info->attributes[n],(const char *) attributes[i],&exception));
6798 if (LocaleCompare(keyword,"image") == 0)
6800 for (j=0; j<msl_info->n;j++)
6803 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6804 if (theAttr && LocaleCompare(theAttr, value) == 0)
6806 watermark = msl_info->image[j];
6812 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6817 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6826 if ( watermark != (Image*) NULL )
6831 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6832 if (newImage == (Image *) NULL)
6834 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6835 msl_info->image[n]=newImage;
6838 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6840 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6843 stereoImage = (Image*)NULL;
6845 if (msl_info->image[n] == (Image *) NULL)
6847 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6850 if (attributes == (const xmlChar **) NULL)
6852 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6854 keyword=(const char *) attributes[i++];
6855 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6856 msl_info->attributes[n],(const char *) attributes[i],&exception));
6862 if (LocaleCompare(keyword,"image") == 0)
6864 for (j=0; j<msl_info->n;j++)
6867 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6868 if (theAttr && LocaleCompare(theAttr, value) == 0)
6870 stereoImage = msl_info->image[j];
6876 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6881 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6890 if ( stereoImage != (Image*) NULL )
6895 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6896 if (newImage == (Image *) NULL)
6898 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6899 msl_info->image[n]=newImage;
6902 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6904 if (LocaleCompare((const char *) tag,"swap") == 0)
6915 if (msl_info->image[n] == (Image *) NULL)
6917 ThrowMSLException(OptionError,"NoImagesDefined",
6918 (const char *) tag);
6923 if (attributes != (const xmlChar **) NULL)
6924 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6926 keyword=(const char *) attributes[i++];
6927 attribute=InterpretImageProperties(msl_info->image_info[n],
6928 msl_info->attributes[n],(const char *) attributes[i],
6930 CloneString(&value,attribute);
6936 if (LocaleCompare(keyword,"indexes") == 0)
6938 flags=ParseGeometry(value,&geometry_info);
6939 index=(ssize_t) geometry_info.rho;
6940 if ((flags & SigmaValue) == 0)
6941 swap_index=(ssize_t) geometry_info.sigma;
6944 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6959 p=GetImageFromList(msl_info->image[n],index);
6960 q=GetImageFromList(msl_info->image[n],swap_index);
6961 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6963 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6966 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6967 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6968 ReplaceImageInList(&q,swap);
6969 msl_info->image[n]=GetFirstImageInList(q);
6972 if (LocaleCompare((const char *) tag,"swirl") == 0)
6980 if (msl_info->image[n] == (Image *) NULL)
6982 ThrowMSLException(OptionError,"NoImagesDefined",
6983 (const char *) tag);
6986 if (attributes != (const xmlChar **) NULL)
6987 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6989 keyword=(const char *) attributes[i++];
6990 attribute=InterpretImageProperties(msl_info->image_info[n],
6991 msl_info->attributes[n],(const char *) attributes[i],
6993 CloneString(&value,attribute);
6999 if (LocaleCompare(keyword,"degrees") == 0)
7001 geometry_info.rho=InterpretLocaleValue(value,
7005 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7012 if (LocaleCompare(keyword,"geometry") == 0)
7014 flags=ParseGeometry(value,&geometry_info);
7015 if ((flags & SigmaValue) == 0)
7016 geometry_info.sigma=1.0;
7019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7025 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7031 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
7032 &msl_info->image[n]->exception);
7033 if (swirl_image == (Image *) NULL)
7035 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7036 msl_info->image[n]=swirl_image;
7039 if (LocaleCompare((const char *) tag,"sync") == 0)
7044 if (msl_info->image[n] == (Image *) NULL)
7046 ThrowMSLException(OptionError,"NoImagesDefined",
7047 (const char *) tag);
7050 if (attributes != (const xmlChar **) NULL)
7051 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7053 keyword=(const char *) attributes[i++];
7054 attribute=InterpretImageProperties(msl_info->image_info[n],
7055 msl_info->attributes[n],(const char *) attributes[i],
7057 CloneString(&value,attribute);
7062 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7068 (void) SyncImage(msl_info->image[n]);
7071 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7076 if (LocaleCompare((const char *) tag,"map") == 0)
7084 if (msl_info->image[n] == (Image *) NULL)
7086 ThrowMSLException(OptionError,"NoImagesDefined",
7087 (const char *) tag);
7090 texture_image=NewImageList();
7091 if (attributes != (const xmlChar **) NULL)
7092 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7094 keyword=(const char *) attributes[i++];
7095 attribute=InterpretImageProperties(msl_info->image_info[n],
7096 msl_info->attributes[n],(const char *) attributes[i],
7098 CloneString(&value,attribute);
7104 if (LocaleCompare(keyword,"image") == 0)
7105 for (j=0; j < msl_info->n; j++)
7110 attribute=GetImageProperty(msl_info->attributes[j],"id");
7111 if ((attribute != (const char *) NULL) &&
7112 (LocaleCompare(attribute,value) == 0))
7114 texture_image=CloneImage(msl_info->image[j],0,0,
7115 MagickFalse,&exception);
7123 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7129 (void) TextureImage(msl_info->image[n],texture_image);
7130 texture_image=DestroyImage(texture_image);
7133 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7135 /* init the values */
7136 double threshold = 0;
7138 if (msl_info->image[n] == (Image *) NULL)
7140 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7143 if (attributes == (const xmlChar **) NULL)
7145 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7147 keyword=(const char *) attributes[i++];
7148 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7149 msl_info->attributes[n],(const char *) attributes[i],&exception));
7155 if (LocaleCompare(keyword,"threshold") == 0)
7157 threshold = InterpretLocaleValue(value,(char **) NULL);
7160 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7165 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7175 BilevelImage(msl_info->image[n],threshold);
7179 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7181 if (msl_info->image[n] == (Image *) NULL)
7183 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7186 if (attributes == (const xmlChar **) NULL)
7188 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7190 keyword=(const char *) attributes[i++];
7191 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7192 msl_info->attributes[n],(const char *) attributes[i],&exception));
7198 if (LocaleCompare(keyword,"color") == 0)
7203 (void) QueryMagickColor(value,&target,&exception);
7204 (void) TransparentPaintImage(msl_info->image[n],&target,
7205 TransparentAlpha,MagickFalse,&msl_info->image[n]->exception);
7208 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7213 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7220 else if (LocaleCompare((const char *) tag, "trim") == 0)
7222 if (msl_info->image[n] == (Image *) NULL)
7224 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7228 /* no attributes here */
7230 /* process the image */
7237 /* all zeros on a crop == trim edges! */
7238 rectInfo.height = rectInfo.width = 0;
7239 rectInfo.x = rectInfo.y = 0;
7241 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7242 if (newImage == (Image *) NULL)
7244 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7245 msl_info->image[n]=newImage;
7249 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7254 if (LocaleCompare((const char *) tag,"write") == 0)
7256 if (msl_info->image[n] == (Image *) NULL)
7258 ThrowMSLException(OptionError,"NoImagesDefined",
7259 (const char *) tag);
7262 if (attributes == (const xmlChar **) NULL)
7264 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7266 keyword=(const char *) attributes[i++];
7267 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7268 msl_info->attributes[n],(const char *) attributes[i],&exception));
7274 if (LocaleCompare(keyword,"filename") == 0)
7276 (void) CopyMagickString(msl_info->image[n]->filename,value,
7280 (void) SetMSLAttributes(msl_info,keyword,value);
7284 (void) SetMSLAttributes(msl_info,keyword,value);
7292 (void) WriteImage(msl_info->image_info[n], msl_info->image[n],
7293 &msl_info->image[n]->exception);
7297 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7301 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7305 if ( value != NULL )
7306 value=DestroyString(value);
7307 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7310 static void MSLEndElement(void *context,const xmlChar *tag)
7319 Called when the end of an element has been detected.
7321 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7323 msl_info=(MSLInfo *) context;
7330 if (LocaleCompare((const char *) tag,"comment") == 0 )
7332 (void) DeleteImageProperty(msl_info->image[n],"comment");
7333 if (msl_info->content == (char *) NULL)
7335 StripString(msl_info->content);
7336 (void) SetImageProperty(msl_info->image[n],"comment",
7345 if (LocaleCompare((const char *) tag, "group") == 0 )
7347 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7349 ssize_t i = (ssize_t)
7350 (msl_info->group_info[msl_info->number_groups-1].numImages);
7353 if (msl_info->image[msl_info->n] != (Image *) NULL)
7354 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7355 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7356 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7360 msl_info->number_groups--;
7367 if (LocaleCompare((const char *) tag, "image") == 0)
7368 MSLPopImage(msl_info);
7374 if (LocaleCompare((const char *) tag,"label") == 0 )
7376 (void) DeleteImageProperty(msl_info->image[n],"label");
7377 if (msl_info->content == (char *) NULL)
7379 StripString(msl_info->content);
7380 (void) SetImageProperty(msl_info->image[n],"label",
7389 if (LocaleCompare((const char *) tag, "msl") == 0 )
7392 This our base element.
7393 at the moment we don't do anything special
7394 but someday we might!
7402 if (msl_info->content != (char *) NULL)
7403 msl_info->content=DestroyString(msl_info->content);
7406 static void MSLCharacters(void *context,const xmlChar *c,int length)
7418 Receiving some characters from the parser.
7420 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7421 " SAX.characters(%s,%d)",c,length);
7422 msl_info=(MSLInfo *) context;
7423 if (msl_info->content != (char *) NULL)
7424 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7425 strlen(msl_info->content)+length+MaxTextExtent,
7426 sizeof(*msl_info->content));
7429 msl_info->content=(char *) NULL;
7430 if (~length >= (MaxTextExtent-1))
7431 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7432 sizeof(*msl_info->content));
7433 if (msl_info->content != (char *) NULL)
7434 *msl_info->content='\0';
7436 if (msl_info->content == (char *) NULL)
7438 p=msl_info->content+strlen(msl_info->content);
7439 for (i=0; i < length; i++)
7444 static void MSLReference(void *context,const xmlChar *name)
7453 Called when an entity reference is detected.
7455 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7456 " SAX.reference(%s)",name);
7457 msl_info=(MSLInfo *) context;
7458 parser=msl_info->parser;
7460 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7462 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7465 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7471 Receiving some ignorable whitespaces from the parser.
7473 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7474 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7475 msl_info=(MSLInfo *) context;
7479 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7480 const xmlChar *data)
7486 A processing instruction has been parsed.
7488 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7489 " SAX.processingInstruction(%s, %s)",
7491 msl_info=(MSLInfo *) context;
7495 static void MSLComment(void *context,const xmlChar *value)
7501 A comment has been parsed.
7503 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7504 " SAX.comment(%s)",value);
7505 msl_info=(MSLInfo *) context;
7509 static void MSLWarning(void *context,const char *format,...)
7513 reason[MaxTextExtent];
7522 Display and format a warning messages, gives file, line, position and
7525 va_start(operands,format);
7526 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7527 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7528 msl_info=(MSLInfo *) context;
7530 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7531 (void) vsprintf(reason,format,operands);
7533 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7535 message=GetExceptionMessage(errno);
7536 ThrowMSLException(CoderError,reason,message);
7537 message=DestroyString(message);
7541 static void MSLError(void *context,const char *format,...)
7544 reason[MaxTextExtent];
7553 Display and format a error formats, gives file, line, position and
7556 va_start(operands,format);
7557 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7558 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7559 msl_info=(MSLInfo *) context;
7561 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7562 (void) vsprintf(reason,format,operands);
7564 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7566 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7570 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7582 Called when a pcdata block has been parsed.
7584 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7585 " SAX.pcdata(%s, %d)",value,length);
7586 msl_info=(MSLInfo *) context;
7588 parser=msl_info->parser;
7589 child=xmlGetLastChild(parser->node);
7590 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7592 xmlTextConcat(child,value,length);
7595 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7598 static void MSLExternalSubset(void *context,const xmlChar *name,
7599 const xmlChar *external_id,const xmlChar *system_id)
7614 Does this document has an external subset?
7616 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7617 " SAX.externalSubset(%s %s %s)",name,
7618 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7619 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7620 msl_info=(MSLInfo *) context;
7622 parser=msl_info->parser;
7623 if (((external_id == NULL) && (system_id == NULL)) ||
7624 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7625 (msl_info->document == 0)))
7627 input=MSLResolveEntity(context,external_id,system_id);
7630 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7631 parser_context=(*parser);
7632 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7633 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7635 parser->errNo=XML_ERR_NO_MEMORY;
7636 parser->input=parser_context.input;
7637 parser->inputNr=parser_context.inputNr;
7638 parser->inputMax=parser_context.inputMax;
7639 parser->inputTab=parser_context.inputTab;
7645 xmlPushInput(parser,input);
7646 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7647 if (input->filename == (char *) NULL)
7648 input->filename=(char *) xmlStrdup(system_id);
7651 input->base=parser->input->cur;
7652 input->cur=parser->input->cur;
7654 xmlParseExternalSubset(parser,external_id,system_id);
7655 while (parser->inputNr > 1)
7656 (void) xmlPopInput(parser);
7657 xmlFreeInputStream(parser->input);
7658 xmlFree(parser->inputTab);
7659 parser->input=parser_context.input;
7660 parser->inputNr=parser_context.inputNr;
7661 parser->inputMax=parser_context.inputMax;
7662 parser->inputTab=parser_context.inputTab;
7665 #if defined(__cplusplus) || defined(c_plusplus)
7669 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7670 ExceptionInfo *exception)
7673 message[MaxTextExtent];
7696 assert(image_info != (const ImageInfo *) NULL);
7697 assert(image_info->signature == MagickSignature);
7698 if (image_info->debug != MagickFalse)
7699 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7700 image_info->filename);
7701 assert(image != (Image **) NULL);
7702 msl_image=AcquireImage(image_info);
7703 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7704 if (status == MagickFalse)
7706 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7707 msl_image->filename);
7708 msl_image=DestroyImageList(msl_image);
7709 return(MagickFalse);
7711 msl_image->columns=1;
7716 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7717 msl_info.exception=exception;
7718 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7719 sizeof(*msl_info.image_info));
7720 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7721 sizeof(*msl_info.draw_info));
7722 /* top of the stack is the MSL file itself */
7723 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7724 msl_info.attributes=(Image **) AcquireMagickMemory(
7725 sizeof(*msl_info.attributes));
7726 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7727 sizeof(*msl_info.group_info));
7728 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7729 (msl_info.image == (Image **) NULL) ||
7730 (msl_info.attributes == (Image **) NULL) ||
7731 (msl_info.group_info == (MSLGroupInfo *) NULL))
7732 ThrowFatalException(ResourceLimitFatalError,
7733 "UnableToInterpretMSLImage");
7734 *msl_info.image_info=CloneImageInfo(image_info);
7735 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7736 *msl_info.attributes=AcquireImage(image_info);
7737 msl_info.group_info[0].numImages=0;
7738 /* the first slot is used to point to the MSL file image */
7739 *msl_info.image=msl_image;
7740 if (*image != (Image *) NULL)
7741 MSLPushImage(&msl_info,*image);
7742 (void) xmlSubstituteEntitiesDefault(1);
7743 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7744 sax_modules.internalSubset=MSLInternalSubset;
7745 sax_modules.isStandalone=MSLIsStandalone;
7746 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7747 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7748 sax_modules.resolveEntity=MSLResolveEntity;
7749 sax_modules.getEntity=MSLGetEntity;
7750 sax_modules.entityDecl=MSLEntityDeclaration;
7751 sax_modules.notationDecl=MSLNotationDeclaration;
7752 sax_modules.attributeDecl=MSLAttributeDeclaration;
7753 sax_modules.elementDecl=MSLElementDeclaration;
7754 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7755 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7756 sax_modules.startDocument=MSLStartDocument;
7757 sax_modules.endDocument=MSLEndDocument;
7758 sax_modules.startElement=MSLStartElement;
7759 sax_modules.endElement=MSLEndElement;
7760 sax_modules.reference=MSLReference;
7761 sax_modules.characters=MSLCharacters;
7762 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7763 sax_modules.processingInstruction=MSLProcessingInstructions;
7764 sax_modules.comment=MSLComment;
7765 sax_modules.warning=MSLWarning;
7766 sax_modules.error=MSLError;
7767 sax_modules.fatalError=MSLError;
7768 sax_modules.getParameterEntity=MSLGetParameterEntity;
7769 sax_modules.cdataBlock=MSLCDataBlock;
7770 sax_modules.externalSubset=MSLExternalSubset;
7771 sax_handler=(&sax_modules);
7772 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7773 msl_image->filename);
7774 while (ReadBlobString(msl_image,message) != (char *) NULL)
7776 n=(ssize_t) strlen(message);
7779 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7782 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7783 if (msl_info.exception->severity >= ErrorException)
7786 if (msl_info.exception->severity == UndefinedException)
7787 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7788 xmlFreeParserCtxt(msl_info.parser);
7789 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7791 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7792 msl_info.group_info);
7793 if (*image == (Image *) NULL)
7794 *image=(*msl_info.image);
7795 if ((*msl_info.image)->exception.severity != UndefinedException)
7796 return(MagickFalse);
7800 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
7808 assert(image_info != (const ImageInfo *) NULL);
7809 assert(image_info->signature == MagickSignature);
7810 if (image_info->debug != MagickFalse)
7811 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7812 image_info->filename);
7813 assert(exception != (ExceptionInfo *) NULL);
7814 assert(exception->signature == MagickSignature);
7815 image=(Image *) NULL;
7816 (void) ProcessMSLScript(image_info,&image,exception);
7817 return(GetFirstImageInList(image));
7822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7826 % R e g i s t e r M S L I m a g e %
7830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7832 % RegisterMSLImage() adds attributes for the MSL image format to
7833 % the list of supported formats. The attributes include the image format
7834 % tag, a method to read and/or write the format, whether the format
7835 % supports the saving of more than one frame to the same file or blob,
7836 % whether the format supports native in-memory I/O, and a brief
7837 % description of the format.
7839 % The format of the RegisterMSLImage method is:
7841 % size_t RegisterMSLImage(void)
7844 ModuleExport size_t RegisterMSLImage(void)
7849 entry=SetMagickInfo("MSL");
7850 #if defined(MAGICKCORE_XML_DELEGATE)
7851 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7852 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7854 entry->description=ConstantString("Magick Scripting Language");
7855 entry->module=ConstantString("MSL");
7856 (void) RegisterMagickInfo(entry);
7857 return(MagickImageCoderSignature);
7860 #if defined(MAGICKCORE_XML_DELEGATE)
7862 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7866 % S e t M S L A t t r i b u t e s %
7870 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7872 % SetMSLAttributes() ...
7874 % The format of the SetMSLAttributes method is:
7876 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7877 % const char *keyword,const char *value)
7879 % A description of each parameter follows:
7881 % o msl_info: the MSL info.
7883 % o keyword: the keyword.
7885 % o value: the value.
7888 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7915 assert(msl_info != (MSLInfo *) NULL);
7916 if (keyword == (const char *) NULL)
7918 if (value == (const char *) NULL)
7920 exception=msl_info->exception;
7922 attributes=msl_info->attributes[n];
7923 image_info=msl_info->image_info[n];
7924 draw_info=msl_info->draw_info[n];
7925 image=msl_info->image[n];
7931 if (LocaleCompare(keyword,"adjoin") == 0)
7936 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7938 ThrowMSLException(OptionError,"UnrecognizedType",value);
7939 image_info->adjoin=(MagickBooleanType) adjoin;
7942 if (LocaleCompare(keyword,"alpha") == 0)
7947 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7949 ThrowMSLException(OptionError,"UnrecognizedType",value);
7950 if (image != (Image *) NULL)
7951 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha,
7955 if (LocaleCompare(keyword,"antialias") == 0)
7960 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7962 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7963 image_info->antialias=(MagickBooleanType) antialias;
7966 if (LocaleCompare(keyword,"area-limit") == 0)
7971 limit=MagickResourceInfinity;
7972 if (LocaleCompare(value,"unlimited") != 0)
7973 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7974 (void) SetMagickResourceLimit(AreaResource,limit);
7977 if (LocaleCompare(keyword,"attenuate") == 0)
7979 (void) SetImageOption(image_info,keyword,value);
7982 if (LocaleCompare(keyword,"authenticate") == 0)
7984 (void) CloneString(&image_info->density,value);
7987 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7993 if (LocaleCompare(keyword,"background") == 0)
7995 (void) QueryColorDatabase(value,&image_info->background_color,
7999 if (LocaleCompare(keyword,"bias") == 0)
8001 if (image == (Image *) NULL)
8003 image->bias=SiPrefixToDouble(value,QuantumRange);
8006 if (LocaleCompare(keyword,"blue-primary") == 0)
8008 if (image == (Image *) NULL)
8010 flags=ParseGeometry(value,&geometry_info);
8011 image->chromaticity.blue_primary.x=geometry_info.rho;
8012 image->chromaticity.blue_primary.y=geometry_info.sigma;
8013 if ((flags & SigmaValue) == 0)
8014 image->chromaticity.blue_primary.y=
8015 image->chromaticity.blue_primary.x;
8018 if (LocaleCompare(keyword,"bordercolor") == 0)
8020 (void) QueryColorDatabase(value,&image_info->border_color,
8024 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8030 if (LocaleCompare(keyword,"density") == 0)
8032 (void) CloneString(&image_info->density,value);
8033 (void) CloneString(&draw_info->density,value);
8036 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8042 if (LocaleCompare(keyword,"fill") == 0)
8044 (void) QueryColorDatabase(value,&draw_info->fill,exception);
8045 (void) SetImageOption(image_info,keyword,value);
8048 if (LocaleCompare(keyword,"filename") == 0)
8050 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
8053 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8059 if (LocaleCompare(keyword,"gravity") == 0)
8064 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
8066 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
8067 (void) SetImageOption(image_info,keyword,value);
8070 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8076 if (LocaleCompare(keyword,"id") == 0)
8078 (void) SetImageProperty(attributes,keyword,value);
8081 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8087 if (LocaleCompare(keyword,"magick") == 0)
8089 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
8092 if (LocaleCompare(keyword,"mattecolor") == 0)
8094 (void) QueryColorDatabase(value,&image_info->matte_color,
8098 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8104 if (LocaleCompare(keyword,"pointsize") == 0)
8106 image_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8107 draw_info->pointsize=InterpretLocaleValue(value,(char **) NULL);
8110 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8116 if (LocaleCompare(keyword,"quality") == 0)
8118 image_info->quality=StringToLong(value);
8119 if (image == (Image *) NULL)
8121 image->quality=StringToLong(value);
8129 if (LocaleCompare(keyword,"size") == 0)
8131 (void) CloneString(&image_info->size,value);
8134 if (LocaleCompare(keyword,"stroke") == 0)
8136 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8137 (void) SetImageOption(image_info,keyword,value);
8140 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8145 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8158 % U n r e g i s t e r M S L I m a g e %
8162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8164 % UnregisterMSLImage() removes format registrations made by the
8165 % MSL module from the list of supported formats.
8167 % The format of the UnregisterMSLImage method is:
8169 % UnregisterMSLImage(void)
8172 ModuleExport void UnregisterMSLImage(void)
8174 (void) UnregisterMagickInfo("MSL");
8177 #if defined(MAGICKCORE_XML_DELEGATE)
8179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8183 % W r i t e M S L I m a g e %
8187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8189 % WriteMSLImage() writes an image to a file in MVG image format.
8191 % The format of the WriteMSLImage method is:
8193 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,
8194 % Image *image,ExceptionInfo *exception)
8196 % A description of each parameter follows.
8198 % o image_info: the image info.
8200 % o image: The image.
8202 % o exception: return any errors or warnings in this structure.
8205 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image,
8206 ExceptionInfo *exception)
8208 assert(image_info != (const ImageInfo *) NULL);
8209 assert(image_info->signature == MagickSignature);
8210 assert(image != (Image *) NULL);
8211 assert(image->signature == MagickSignature);
8212 if (image->debug != MagickFalse)
8213 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8214 (void) ReferenceImage(image);
8215 (void) ProcessMSLScript(image_info,&image,exception);