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 "magick/studio.h"
45 #include "magick/annotate.h"
46 #include "magick/artifact.h"
47 #include "magick/blob.h"
48 #include "magick/blob-private.h"
49 #include "magick/cache.h"
50 #include "magick/cache-view.h"
51 #include "magick/color.h"
52 #include "magick/colormap.h"
53 #include "magick/color-private.h"
54 #include "magick/composite.h"
55 #include "magick/constitute.h"
56 #include "magick/decorate.h"
57 #include "magick/display.h"
58 #include "magick/draw.h"
59 #include "magick/effect.h"
60 #include "magick/enhance.h"
61 #include "magick/exception.h"
62 #include "magick/exception-private.h"
63 #include "magick/fx.h"
64 #include "magick/geometry.h"
65 #include "magick/image.h"
66 #include "magick/image-private.h"
67 #include "magick/list.h"
68 #include "magick/log.h"
69 #include "magick/magick.h"
70 #include "magick/memory_.h"
71 #include "magick/module.h"
72 #include "magick/option.h"
73 #include "magick/paint.h"
74 #include "magick/profile.h"
75 #include "magick/property.h"
76 #include "magick/quantize.h"
77 #include "magick/quantum-private.h"
78 #include "magick/registry.h"
79 #include "magick/resize.h"
80 #include "magick/resource_.h"
81 #include "magick/segment.h"
82 #include "magick/shear.h"
83 #include "magick/signature.h"
84 #include "magick/static.h"
85 #include "magick/string_.h"
86 #include "magick/string-private.h"
87 #include "magick/transform.h"
88 #include "magick/threshold.h"
89 #include "magick/utility.h"
90 #if defined(MAGICKCORE_XML_DELEGATE)
91 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
92 # if defined(__MINGW32__)
95 # include <win32config.h>
98 # include <libxml/parser.h>
99 # include <libxml/xmlmemory.h>
100 # include <libxml/parserInternals.h>
101 # include <libxml/xmlerror.h>
107 #define ThrowMSLException(severity,tag,reason) \
108 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \
112 Typedef declaractions.
114 typedef struct _MSLGroupInfo
117 numImages; /* how many images are in this group */
120 typedef struct _MSLInfo
145 #if defined(MAGICKCORE_XML_DELEGATE)
155 Forward declarations.
157 #if defined(MAGICKCORE_XML_DELEGATE)
158 static MagickBooleanType
159 WriteMSLImage(const ImageInfo *,Image *);
161 static MagickBooleanType
162 SetMSLAttributes(MSLInfo *,const char *,const char *);
165 #if defined(MAGICKCORE_XML_DELEGATE)
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 % R e a d M S L I m a g e %
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 % ReadMSLImage() reads a Magick Scripting Language file and returns it.
179 % It allocates the memory necessary for the new Image structure and returns a
180 % pointer to the new image.
182 % The format of the ReadMSLImage method is:
184 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
186 % A description of each parameter follows:
188 % o image_info: the image info.
190 % o exception: return any errors or warnings in this structure.
194 #if defined(__cplusplus) || defined(c_plusplus)
198 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
199 ExceptionInfo *exception)
213 (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
214 sans_exception=AcquireExceptionInfo();
215 image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
216 sans_exception=DestroyExceptionInfo(sans_exception);
217 if (image != (Image *) NULL)
219 read_info=CloneImageInfo(image_info);
220 (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
221 image=ReadImage(read_info,exception);
222 read_info=DestroyImageInfo(read_info);
223 if (image != (Image *) NULL)
224 (void) SetImageRegistry(ImageRegistryType,key,image,exception);
228 static int IsPathDirectory(const char *path)
236 if ((path == (const char *) NULL) || (*path == '\0'))
238 status=GetPathAttributes(path,&attributes);
239 if (status == MagickFalse)
241 if (S_ISDIR(attributes.st_mode) == 0)
246 static int MSLIsStandalone(void *context)
252 Is this document tagged standalone?
254 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()");
255 msl_info=(MSLInfo *) context;
256 return(msl_info->document->standalone == 1);
259 static int MSLHasInternalSubset(void *context)
265 Does this document has an internal subset?
267 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
268 " SAX.MSLHasInternalSubset()");
269 msl_info=(MSLInfo *) context;
270 return(msl_info->document->intSubset != NULL);
273 static int MSLHasExternalSubset(void *context)
279 Does this document has an external subset?
281 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
282 " SAX.MSLHasExternalSubset()");
283 msl_info=(MSLInfo *) context;
284 return(msl_info->document->extSubset != NULL);
287 static void MSLInternalSubset(void *context,const xmlChar *name,
288 const xmlChar *external_id,const xmlChar *system_id)
294 Does this document has an internal subset?
296 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
297 " SAX.internalSubset(%s %s %s)",name,
298 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
299 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
300 msl_info=(MSLInfo *) context;
301 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
304 static xmlParserInputPtr MSLResolveEntity(void *context,
305 const xmlChar *public_id,const xmlChar *system_id)
314 Special entity resolver, better left to the parser, it has more
315 context than the application layer. The default behaviour is to
316 not resolve the entities, in that case the ENTITY_REF nodes are
317 built in the structure (and the parameter values).
319 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
320 " SAX.resolveEntity(%s, %s)",
321 (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
322 (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
323 msl_info=(MSLInfo *) context;
324 stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
325 public_id,msl_info->parser);
329 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
335 Get an entity by name.
337 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
338 " SAX.MSLGetEntity(%s)",(const char *) name);
339 msl_info=(MSLInfo *) context;
340 return(xmlGetDocEntity(msl_info->document,name));
343 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
349 Get a parameter entity by name.
351 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
352 " SAX.getParameterEntity(%s)",(const char *) name);
353 msl_info=(MSLInfo *) context;
354 return(xmlGetParameterEntity(msl_info->document,name));
357 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
358 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content)
364 An entity definition has been parsed.
366 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
367 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
368 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
369 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
371 msl_info=(MSLInfo *) context;
372 if (msl_info->parser->inSubset == 1)
373 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
376 if (msl_info->parser->inSubset == 2)
377 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id,
381 static void MSLAttributeDeclaration(void *context,const xmlChar *element,
382 const xmlChar *name,int type,int value,const xmlChar *default_value,
383 xmlEnumerationPtr tree)
396 An attribute definition has been parsed.
398 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
399 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element,name,type,value,
401 msl_info=(MSLInfo *) context;
402 fullname=(xmlChar *) NULL;
403 prefix=(xmlChar *) NULL;
404 parser=msl_info->parser;
405 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix);
406 if (parser->inSubset == 1)
407 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset,
408 element,fullname,prefix,(xmlAttributeType) type,
409 (xmlAttributeDefault) value,default_value,tree);
411 if (parser->inSubset == 2)
412 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset,
413 element,fullname,prefix,(xmlAttributeType) type,
414 (xmlAttributeDefault) value,default_value,tree);
415 if (prefix != (xmlChar *) NULL)
417 if (fullname != (xmlChar *) NULL)
421 static void MSLElementDeclaration(void *context,const xmlChar *name,int type,
422 xmlElementContentPtr content)
431 An element definition has been parsed.
433 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
434 " SAX.elementDecl(%s, %d, ...)",name,type);
435 msl_info=(MSLInfo *) context;
436 parser=msl_info->parser;
437 if (parser->inSubset == 1)
438 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset,
439 name,(xmlElementTypeVal) type,content);
441 if (parser->inSubset == 2)
442 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset,
443 name,(xmlElementTypeVal) type,content);
446 static void MSLNotationDeclaration(void *context,const xmlChar *name,
447 const xmlChar *public_id,const xmlChar *system_id)
456 What to do when a notation declaration has been parsed.
458 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
459 " SAX.notationDecl(%s, %s, %s)",name,
460 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
461 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
462 msl_info=(MSLInfo *) context;
463 parser=msl_info->parser;
464 if (parser->inSubset == 1)
465 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
466 name,public_id,system_id);
468 if (parser->inSubset == 2)
469 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset,
470 name,public_id,system_id);
473 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
474 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation)
480 What to do when an unparsed entity declaration is parsed.
482 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
483 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
484 public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
485 system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
487 msl_info=(MSLInfo *) context;
488 (void) xmlAddDocEntity(msl_info->document,name,
489 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
493 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location)
499 Receive the document locator at startup, actually xmlDefaultSAXLocator.
501 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
502 " SAX.setDocumentLocator()\n");
504 msl_info=(MSLInfo *) context;
508 static void MSLStartDocument(void *context)
517 Called when the document start being processed.
519 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
520 " SAX.startDocument()");
521 msl_info=(MSLInfo *) context;
522 parser=msl_info->parser;
523 msl_info->document=xmlNewDoc(parser->version);
524 if (msl_info->document == (xmlDocPtr) NULL)
526 if (parser->encoding == NULL)
527 msl_info->document->encoding=NULL;
529 msl_info->document->encoding=xmlStrdup(parser->encoding);
530 msl_info->document->standalone=parser->standalone;
533 static void MSLEndDocument(void *context)
539 Called when the document end has been detected.
541 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()");
542 msl_info=(MSLInfo *) context;
543 if (msl_info->content != (char *) NULL)
544 msl_info->content=DestroyString(msl_info->content);
547 static void MSLPushImage(MSLInfo *msl_info,Image *image)
552 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
553 assert(msl_info != (MSLInfo *) NULL);
556 msl_info->image_info=(ImageInfo **) ResizeQuantumMemory(msl_info->image_info,
557 (n+1),sizeof(*msl_info->image_info));
558 msl_info->draw_info=(DrawInfo **) ResizeQuantumMemory(msl_info->draw_info,
559 (n+1),sizeof(*msl_info->draw_info));
560 msl_info->attributes=(Image **) ResizeQuantumMemory(msl_info->attributes,
561 (n+1),sizeof(*msl_info->attributes));
562 msl_info->image=(Image **) ResizeQuantumMemory(msl_info->image,(n+1),
563 sizeof(*msl_info->image));
564 if ((msl_info->image_info == (ImageInfo **) NULL) ||
565 (msl_info->draw_info == (DrawInfo **) NULL) ||
566 (msl_info->attributes == (Image **) NULL) ||
567 (msl_info->image == (Image **) NULL))
568 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
569 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]);
570 msl_info->draw_info[n]=CloneDrawInfo(msl_info->image_info[n-1],
571 msl_info->draw_info[n-1]);
572 if (image == (Image *) NULL)
573 msl_info->attributes[n]=AcquireImage(msl_info->image_info[n]);
575 msl_info->attributes[n]=CloneImage(image,0,0,MagickTrue,&image->exception);
576 msl_info->image[n]=(Image *) image;
577 if ((msl_info->image_info[n] == (ImageInfo *) NULL) ||
578 (msl_info->attributes[n] == (Image *) NULL))
579 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl");
580 if (msl_info->number_groups != 0)
581 msl_info->group_info[msl_info->number_groups-1].numImages++;
584 static void MSLPopImage(MSLInfo *msl_info)
586 if (msl_info->number_groups != 0)
588 if (msl_info->image[msl_info->n] != (Image *) NULL)
589 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
590 msl_info->attributes[msl_info->n]=DestroyImage(
591 msl_info->attributes[msl_info->n]);
592 msl_info->image_info[msl_info->n]=DestroyImageInfo(
593 msl_info->image_info[msl_info->n]);
597 static void MSLStartElement(void *context,const xmlChar *tag,
598 const xmlChar **attributes)
654 Called when an opening tag has been processed.
656 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
657 " SAX.startElement(%s",tag);
658 GetExceptionInfo(&exception);
659 msl_info=(MSLInfo *) context;
661 keyword=(const char *) NULL;
663 SetGeometryInfo(&geometry_info);
664 channel=DefaultChannels;
670 if (LocaleCompare((const char *) tag,"add-noise") == 0)
681 if (msl_info->image[n] == (Image *) NULL)
683 ThrowMSLException(OptionError,"NoImagesDefined",
688 if (attributes != (const xmlChar **) NULL)
689 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
691 keyword=(const char *) attributes[i++];
692 attribute=InterpretImageProperties(msl_info->image_info[n],
693 msl_info->attributes[n],(const char *) attributes[i]);
694 CloneString(&value,attribute);
700 if (LocaleCompare(keyword,"channel") == 0)
702 option=ParseChannelOption(value);
704 ThrowMSLException(OptionError,"UnrecognizedChannelType",
706 channel=(ChannelType) option;
709 ThrowMSLException(OptionError,"UnrecognizedAttribute",
716 if (LocaleCompare(keyword,"noise") == 0)
718 option=ParseCommandOption(MagickNoiseOptions,MagickFalse,
721 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
723 noise=(NoiseType) option;
726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
732 ThrowMSLException(OptionError,"UnrecognizedAttribute",
738 noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise,
739 &msl_info->image[n]->exception);
740 if (noise_image == (Image *) NULL)
742 msl_info->image[n]=DestroyImage(msl_info->image[n]);
743 msl_info->image[n]=noise_image;
746 if (LocaleCompare((const char *) tag,"annotate") == 0)
754 if (msl_info->image[n] == (Image *) NULL)
756 ThrowMSLException(OptionError,"NoImagesDefined",
760 draw_info=CloneDrawInfo(msl_info->image_info[n],
761 msl_info->draw_info[n]);
763 current=draw_info->affine;
764 GetAffineMatrix(&affine);
765 if (attributes != (const xmlChar **) NULL)
766 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
768 keyword=(const char *) attributes[i++];
769 attribute=InterpretImageProperties(msl_info->image_info[n],
770 msl_info->attributes[n],(const char *) attributes[i]);
771 CloneString(&value,attribute);
777 if (LocaleCompare(keyword,"affine") == 0)
783 draw_info->affine.sx=strtod(p,&p);
786 draw_info->affine.rx=strtod(p,&p);
789 draw_info->affine.ry=strtod(p,&p);
792 draw_info->affine.sy=strtod(p,&p);
795 draw_info->affine.tx=strtod(p,&p);
798 draw_info->affine.ty=strtod(p,&p);
801 if (LocaleCompare(keyword,"align") == 0)
803 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
806 ThrowMSLException(OptionError,"UnrecognizedAlignType",
808 draw_info->align=(AlignType) option;
811 if (LocaleCompare(keyword,"antialias") == 0)
813 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
816 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
818 draw_info->stroke_antialias=(MagickBooleanType) option;
819 draw_info->text_antialias=(MagickBooleanType) option;
822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
829 if (LocaleCompare(keyword,"density") == 0)
831 CloneString(&draw_info->density,value);
834 ThrowMSLException(OptionError,"UnrecognizedAttribute",
841 if (LocaleCompare(keyword,"encoding") == 0)
843 CloneString(&draw_info->encoding,value);
846 ThrowMSLException(OptionError,"UnrecognizedAttribute",
853 if (LocaleCompare(keyword, "fill") == 0)
855 (void) QueryColorDatabase(value,&draw_info->fill,
859 if (LocaleCompare(keyword,"family") == 0)
861 CloneString(&draw_info->family,value);
864 if (LocaleCompare(keyword,"font") == 0)
866 CloneString(&draw_info->font,value);
869 ThrowMSLException(OptionError,"UnrecognizedAttribute",
876 if (LocaleCompare(keyword,"geometry") == 0)
878 flags=ParsePageGeometry(msl_info->image[n],value,
879 &geometry,&exception);
880 if ((flags & HeightValue) == 0)
881 geometry.height=geometry.width;
884 if (LocaleCompare(keyword,"gravity") == 0)
886 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
889 ThrowMSLException(OptionError,"UnrecognizedGravityType",
891 draw_info->gravity=(GravityType) option;
894 ThrowMSLException(OptionError,"UnrecognizedAttribute",
901 if (LocaleCompare(keyword,"pointsize") == 0)
903 draw_info->pointsize=StringToDouble(value);
906 ThrowMSLException(OptionError,"UnrecognizedAttribute",
913 if (LocaleCompare(keyword,"rotate") == 0)
915 angle=StringToDouble(value);
916 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
917 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
918 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
919 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
922 ThrowMSLException(OptionError,"UnrecognizedAttribute",
929 if (LocaleCompare(keyword,"scale") == 0)
931 flags=ParseGeometry(value,&geometry_info);
932 if ((flags & SigmaValue) == 0)
933 geometry_info.sigma=1.0;
934 affine.sx=geometry_info.rho;
935 affine.sy=geometry_info.sigma;
938 if (LocaleCompare(keyword,"skewX") == 0)
940 angle=StringToDouble(value);
941 affine.ry=tan(DegreesToRadians(fmod((double) angle,
945 if (LocaleCompare(keyword,"skewY") == 0)
947 angle=StringToDouble(value);
948 affine.rx=tan(DegreesToRadians(fmod((double) angle,
952 if (LocaleCompare(keyword,"stretch") == 0)
954 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
957 ThrowMSLException(OptionError,"UnrecognizedStretchType",
959 draw_info->stretch=(StretchType) option;
962 if (LocaleCompare(keyword, "stroke") == 0)
964 (void) QueryColorDatabase(value,&draw_info->stroke,
968 if (LocaleCompare(keyword,"strokewidth") == 0)
970 draw_info->stroke_width=StringToLong(value);
973 if (LocaleCompare(keyword,"style") == 0)
975 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
978 ThrowMSLException(OptionError,"UnrecognizedStyleType",
980 draw_info->style=(StyleType) option;
983 ThrowMSLException(OptionError,"UnrecognizedAttribute",
990 if (LocaleCompare(keyword,"text") == 0)
992 CloneString(&draw_info->text,value);
995 if (LocaleCompare(keyword,"translate") == 0)
997 flags=ParseGeometry(value,&geometry_info);
998 if ((flags & SigmaValue) == 0)
999 geometry_info.sigma=1.0;
1000 affine.tx=geometry_info.rho;
1001 affine.ty=geometry_info.sigma;
1004 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1011 if (LocaleCompare(keyword, "undercolor") == 0)
1013 (void) QueryColorDatabase(value,&draw_info->undercolor,
1017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1024 if (LocaleCompare(keyword,"weight") == 0)
1026 draw_info->weight=StringToLong(value);
1029 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1036 if (LocaleCompare(keyword,"x") == 0)
1038 geometry.x=StringToLong(value);
1041 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1048 if (LocaleCompare(keyword,"y") == 0)
1050 geometry.y=StringToLong(value);
1053 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1059 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1065 (void) FormatMagickString(text,MaxTextExtent,
1066 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
1067 geometry.height,(double) geometry.x,(double) geometry.y);
1068 CloneString(&draw_info->geometry,text);
1069 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
1070 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
1071 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
1072 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
1073 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
1075 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
1077 (void) AnnotateImage(msl_info->image[n],draw_info);
1078 draw_info=DestroyDrawInfo(draw_info);
1081 if (LocaleCompare((const char *) tag,"append") == 0)
1089 if (msl_info->image[n] == (Image *) NULL)
1091 ThrowMSLException(OptionError,"NoImagesDefined",
1092 (const char *) tag);
1096 if (attributes != (const xmlChar **) NULL)
1097 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1099 keyword=(const char *) attributes[i++];
1100 attribute=InterpretImageProperties(msl_info->image_info[n],
1101 msl_info->attributes[n],(const char *) attributes[i]);
1102 CloneString(&value,attribute);
1108 if (LocaleCompare(keyword,"stack") == 0)
1110 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1113 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1115 stack=(MagickBooleanType) option;
1118 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1124 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1130 append_image=AppendImages(msl_info->image[n],stack,
1131 &msl_info->image[n]->exception);
1132 if (append_image == (Image *) NULL)
1134 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1135 msl_info->image[n]=append_image;
1138 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1144 if (LocaleCompare((const char *) tag,"blur") == 0)
1152 if (msl_info->image[n] == (Image *) NULL)
1154 ThrowMSLException(OptionError,"NoImagesDefined",
1155 (const char *) tag);
1158 if (attributes != (const xmlChar **) NULL)
1159 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1161 keyword=(const char *) attributes[i++];
1162 attribute=InterpretImageProperties(msl_info->image_info[n],
1163 msl_info->attributes[n],(const char *) attributes[i]);
1164 CloneString(&value,attribute);
1170 if (LocaleCompare(keyword,"channel") == 0)
1172 option=ParseChannelOption(value);
1174 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1176 channel=(ChannelType) option;
1179 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1186 if (LocaleCompare(keyword,"geometry") == 0)
1188 flags=ParseGeometry(value,&geometry_info);
1189 if ((flags & SigmaValue) == 0)
1190 geometry_info.sigma=1.0;
1193 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1200 if (LocaleCompare(keyword,"radius") == 0)
1202 geometry_info.rho=StringToDouble(value);
1205 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1212 if (LocaleCompare(keyword,"sigma") == 0)
1214 geometry_info.sigma=StringToLong(value);
1217 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1223 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1229 blur_image=BlurImageChannel(msl_info->image[n],channel,
1230 geometry_info.rho,geometry_info.sigma,
1231 &msl_info->image[n]->exception);
1232 if (blur_image == (Image *) NULL)
1234 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1235 msl_info->image[n]=blur_image;
1238 if (LocaleCompare((const char *) tag,"border") == 0)
1246 if (msl_info->image[n] == (Image *) NULL)
1248 ThrowMSLException(OptionError,"NoImagesDefined",
1249 (const char *) tag);
1252 SetGeometry(msl_info->image[n],&geometry);
1253 if (attributes != (const xmlChar **) NULL)
1254 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1256 keyword=(const char *) attributes[i++];
1257 attribute=InterpretImageProperties(msl_info->image_info[n],
1258 msl_info->attributes[n],(const char *) attributes[i]);
1259 CloneString(&value,attribute);
1265 if (LocaleCompare(keyword,"compose") == 0)
1267 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1270 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1272 msl_info->image[n]->compose=(CompositeOperator) option;
1275 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1282 if (LocaleCompare(keyword, "fill") == 0)
1284 (void) QueryColorDatabase(value,
1285 &msl_info->image[n]->border_color,&exception);
1288 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1295 if (LocaleCompare(keyword,"geometry") == 0)
1297 flags=ParsePageGeometry(msl_info->image[n],value,
1298 &geometry,&exception);
1299 if ((flags & HeightValue) == 0)
1300 geometry.height=geometry.width;
1303 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1310 if (LocaleCompare(keyword,"height") == 0)
1312 geometry.height=StringToLong(value);
1315 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1322 if (LocaleCompare(keyword,"width") == 0)
1324 geometry.width=StringToLong(value);
1327 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1333 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1339 border_image=BorderImage(msl_info->image[n],&geometry,
1340 &msl_info->image[n]->exception);
1341 if (border_image == (Image *) NULL)
1343 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1344 msl_info->image[n]=border_image;
1347 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
1352 if (LocaleCompare((const char *) tag,"colorize") == 0)
1355 opacity[MaxTextExtent];
1366 if (msl_info->image[n] == (Image *) NULL)
1368 ThrowMSLException(OptionError,"NoImagesDefined",
1369 (const char *) tag);
1372 target=msl_info->image[n]->background_color;
1373 (void) CopyMagickString(opacity,"100",MaxTextExtent);
1374 if (attributes != (const xmlChar **) NULL)
1375 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1377 keyword=(const char *) attributes[i++];
1378 attribute=InterpretImageProperties(msl_info->image_info[n],
1379 msl_info->attributes[n],(const char *) attributes[i]);
1380 CloneString(&value,attribute);
1386 if (LocaleCompare(keyword,"fill") == 0)
1388 (void) QueryColorDatabase(value,&target,
1389 &msl_info->image[n]->exception);
1392 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1399 if (LocaleCompare(keyword,"opacity") == 0)
1401 (void) CopyMagickString(opacity,value,MaxTextExtent);
1404 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1416 colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
1417 &msl_info->image[n]->exception);
1418 if (colorize_image == (Image *) NULL)
1420 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1421 msl_info->image[n]=colorize_image;
1424 if (LocaleCompare((const char *) tag, "charcoal") == 0)
1426 double radius = 0.0,
1429 if (msl_info->image[n] == (Image *) NULL)
1431 ThrowMSLException(OptionError,"NoImagesDefined",
1432 (const char *) tag);
1436 NOTE: charcoal can have no attributes, since we use all the defaults!
1438 if (attributes != (const xmlChar **) NULL)
1440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1442 keyword=(const char *) attributes[i++];
1443 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
1444 msl_info->attributes[n],(const char *) attributes[i]));
1450 if (LocaleCompare(keyword, "radius") == 0)
1452 radius = StringToDouble( value );
1455 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1461 if (LocaleCompare(keyword,"sigma") == 0)
1463 sigma = StringToLong( value );
1466 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1471 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
1485 newImage=CharcoalImage(msl_info->image[n],radius,sigma,
1486 &msl_info->image[n]->exception);
1487 if (newImage == (Image *) NULL)
1489 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1490 msl_info->image[n]=newImage;
1494 if (LocaleCompare((const char *) tag,"chop") == 0)
1502 if (msl_info->image[n] == (Image *) NULL)
1504 ThrowMSLException(OptionError,"NoImagesDefined",
1505 (const char *) tag);
1508 SetGeometry(msl_info->image[n],&geometry);
1509 if (attributes != (const xmlChar **) NULL)
1510 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1512 keyword=(const char *) attributes[i++];
1513 attribute=InterpretImageProperties(msl_info->image_info[n],
1514 msl_info->attributes[n],(const char *) attributes[i]);
1515 CloneString(&value,attribute);
1521 if (LocaleCompare(keyword,"geometry") == 0)
1523 flags=ParsePageGeometry(msl_info->image[n],value,
1524 &geometry,&exception);
1525 if ((flags & HeightValue) == 0)
1526 geometry.height=geometry.width;
1529 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1536 if (LocaleCompare(keyword,"height") == 0)
1538 geometry.height=StringToLong(value);
1541 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1548 if (LocaleCompare(keyword,"width") == 0)
1550 geometry.width=StringToLong(value);
1553 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1560 if (LocaleCompare(keyword,"x") == 0)
1562 geometry.x=StringToLong(value);
1565 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1572 if (LocaleCompare(keyword,"y") == 0)
1574 geometry.y=StringToLong(value);
1577 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1589 chop_image=ChopImage(msl_info->image[n],&geometry,
1590 &msl_info->image[n]->exception);
1591 if (chop_image == (Image *) NULL)
1593 msl_info->image[n]=DestroyImage(msl_info->image[n]);
1594 msl_info->image[n]=chop_image;
1597 if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
1606 Color floodfill image.
1608 if (msl_info->image[n] == (Image *) NULL)
1610 ThrowMSLException(OptionError,"NoImagesDefined",
1611 (const char *) tag);
1614 draw_info=CloneDrawInfo(msl_info->image_info[n],
1615 msl_info->draw_info[n]);
1616 SetGeometry(msl_info->image[n],&geometry);
1617 paint_method=FloodfillMethod;
1618 if (attributes != (const xmlChar **) NULL)
1619 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1621 keyword=(const char *) attributes[i++];
1622 attribute=InterpretImageProperties(msl_info->image_info[n],
1623 msl_info->attributes[n],(const char *) attributes[i]);
1624 CloneString(&value,attribute);
1630 if (LocaleCompare(keyword,"bordercolor") == 0)
1632 (void) QueryMagickColor(value,&target,&exception);
1633 paint_method=FillToBorderMethod;
1636 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1643 if (LocaleCompare(keyword,"fill") == 0)
1645 (void) QueryColorDatabase(value,&draw_info->fill,
1649 if (LocaleCompare(keyword,"fuzz") == 0)
1651 msl_info->image[n]->fuzz=StringToDouble(value);
1654 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1661 if (LocaleCompare(keyword,"geometry") == 0)
1663 flags=ParsePageGeometry(msl_info->image[n],value,
1664 &geometry,&exception);
1665 if ((flags & HeightValue) == 0)
1666 geometry.height=geometry.width;
1667 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1668 geometry.x,geometry.y,&target,&exception);
1671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1678 if (LocaleCompare(keyword,"x") == 0)
1680 geometry.x=StringToLong(value);
1681 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1682 geometry.x,geometry.y,&target,&exception);
1685 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1692 if (LocaleCompare(keyword,"y") == 0)
1694 geometry.y=StringToLong(value);
1695 (void) GetOneVirtualMagickPixel(msl_info->image[n],
1696 geometry.x,geometry.y,&target,&exception);
1699 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1705 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1711 (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels,
1712 draw_info,&target,geometry.x,geometry.y,
1713 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
1714 draw_info=DestroyDrawInfo(draw_info);
1717 if (LocaleCompare((const char *) tag,"comment") == 0)
1719 if (LocaleCompare((const char *) tag,"composite") == 0)
1722 composite_geometry[MaxTextExtent];
1737 if (msl_info->image[n] == (Image *) NULL)
1739 ThrowMSLException(OptionError,"NoImagesDefined",
1740 (const char *) tag);
1743 composite_image=NewImageList();
1744 compose=OverCompositeOp;
1745 if (attributes != (const xmlChar **) NULL)
1746 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1748 keyword=(const char *) attributes[i++];
1749 attribute=InterpretImageProperties(msl_info->image_info[n],
1750 msl_info->attributes[n],(const char *) attributes[i]);
1751 CloneString(&value,attribute);
1757 if (LocaleCompare(keyword,"compose") == 0)
1759 option=ParseCommandOption(MagickComposeOptions,MagickFalse,
1762 ThrowMSLException(OptionError,"UnrecognizedComposeType",
1764 compose=(CompositeOperator) option;
1772 if (LocaleCompare(keyword,"image") == 0)
1773 for (j=0; j < msl_info->n; j++)
1778 attribute=GetImageProperty(msl_info->attributes[j],"id");
1779 if ((attribute != (const char *) NULL) &&
1780 (LocaleCompare(attribute,value) == 0))
1782 composite_image=CloneImage(msl_info->image[j],0,0,
1783 MagickFalse,&exception);
1793 if (composite_image == (Image *) NULL)
1795 rotate_image=NewImageList();
1796 SetGeometry(msl_info->image[n],&geometry);
1797 if (attributes != (const xmlChar **) NULL)
1798 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
1800 keyword=(const char *) attributes[i++];
1801 attribute=InterpretImageProperties(msl_info->image_info[n],
1802 msl_info->attributes[n],(const char *) attributes[i]);
1803 CloneString(&value,attribute);
1809 if (LocaleCompare(keyword,"blend") == 0)
1811 (void) SetImageArtifact(composite_image,
1812 "compose:args",value);
1815 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1822 if (LocaleCompare(keyword,"channel") == 0)
1824 option=ParseChannelOption(value);
1826 ThrowMSLException(OptionError,"UnrecognizedChannelType",
1828 channel=(ChannelType) option;
1831 if (LocaleCompare(keyword, "color") == 0)
1833 (void) QueryColorDatabase(value,
1834 &composite_image->background_color,&exception);
1837 if (LocaleCompare(keyword,"compose") == 0)
1839 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1846 if (LocaleCompare(keyword,"geometry") == 0)
1848 flags=ParsePageGeometry(msl_info->image[n],value,
1849 &geometry,&exception);
1850 if ((flags & HeightValue) == 0)
1851 geometry.height=geometry.width;
1852 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
1853 geometry.y,&target,&exception);
1856 if (LocaleCompare(keyword,"gravity") == 0)
1858 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
1861 ThrowMSLException(OptionError,"UnrecognizedGravityType",
1863 msl_info->image[n]->gravity=(GravityType) option;
1866 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1873 if (LocaleCompare(keyword,"image") == 0)
1875 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1882 if (LocaleCompare(keyword,"mask") == 0)
1883 for (j=0; j < msl_info->n; j++)
1888 attribute=GetImageProperty(msl_info->attributes[j],"id");
1889 if ((attribute != (const char *) NULL) &&
1890 (LocaleCompare(value,value) == 0))
1892 SetImageType(composite_image,TrueColorMatteType);
1893 (void) CompositeImage(composite_image,
1894 CopyOpacityCompositeOp,msl_info->image[j],0,0);
1898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1905 if (LocaleCompare(keyword,"opacity") == 0)
1914 register PixelPacket
1920 opacity=QuantumRange-StringToLong(value);
1921 if (compose != DissolveCompositeOp)
1923 (void) SetImageOpacity(composite_image,(Quantum)
1927 (void) SetImageArtifact(msl_info->image[n],
1928 "compose:args",value);
1929 if (composite_image->matte != MagickTrue)
1930 (void) SetImageOpacity(composite_image,OpaqueOpacity);
1931 composite_view=AcquireCacheView(composite_image);
1932 for (y=0; y < (ssize_t) composite_image->rows ; y++)
1934 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
1935 composite_image->columns,1,&exception);
1936 for (x=0; x < (ssize_t) composite_image->columns; x++)
1938 if (q->opacity == OpaqueOpacity)
1939 q->opacity=ClampToQuantum(opacity);
1942 if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
1945 composite_view=DestroyCacheView(composite_view);
1948 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1955 if (LocaleCompare(keyword,"rotate") == 0)
1957 rotate_image=RotateImage(composite_image,StringToDouble(value),
1961 ThrowMSLException(OptionError,"UnrecognizedAttribute",
1968 if (LocaleCompare(keyword,"tile") == 0)
1973 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
1976 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
1978 tile=(MagickBooleanType) option;
1980 if (rotate_image != (Image *) NULL)
1981 (void) SetImageArtifact(rotate_image,
1982 "compose:outside-overlay","false");
1984 (void) SetImageArtifact(composite_image,
1985 "compose:outside-overlay","false");
1986 image=msl_info->image[n];
1987 height=composite_image->rows;
1988 width=composite_image->columns;
1989 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
1990 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
1992 if (rotate_image != (Image *) NULL)
1993 (void) CompositeImage(image,compose,rotate_image,
1996 (void) CompositeImage(image,compose,
1997 composite_image,x,y);
1999 if (rotate_image != (Image *) NULL)
2000 rotate_image=DestroyImage(rotate_image);
2003 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2010 if (LocaleCompare(keyword,"x") == 0)
2012 geometry.x=StringToLong(value);
2013 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2014 geometry.y,&target,&exception);
2017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2024 if (LocaleCompare(keyword,"y") == 0)
2026 geometry.y=StringToLong(value);
2027 (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
2028 geometry.y,&target,&exception);
2031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2043 image=msl_info->image[n];
2044 (void) FormatMagickString(composite_geometry,MaxTextExtent,
2045 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
2046 (double) composite_image->rows,(double) geometry.x,(double)
2048 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
2050 if (rotate_image == (Image *) NULL)
2051 CompositeImageChannel(image,channel,compose,composite_image,
2052 geometry.x,geometry.y);
2058 geometry.x-=(ssize_t) (rotate_image->columns-
2059 composite_image->columns)/2;
2060 geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
2061 CompositeImageChannel(image,channel,compose,rotate_image,
2062 geometry.x,geometry.y);
2063 rotate_image=DestroyImage(rotate_image);
2065 composite_image=DestroyImage(composite_image);
2068 if (LocaleCompare((const char *) tag,"contrast") == 0)
2076 if (msl_info->image[n] == (Image *) NULL)
2078 ThrowMSLException(OptionError,"NoImagesDefined",
2079 (const char *) tag);
2082 sharpen=MagickFalse;
2083 if (attributes != (const xmlChar **) NULL)
2084 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2086 keyword=(const char *) attributes[i++];
2087 attribute=InterpretImageProperties(msl_info->image_info[n],
2088 msl_info->attributes[n],(const char *) attributes[i]);
2089 CloneString(&value,attribute);
2095 if (LocaleCompare(keyword,"sharpen") == 0)
2097 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2100 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2102 sharpen=(MagickBooleanType) option;
2105 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2111 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2117 (void) ContrastImage(msl_info->image[n],sharpen);
2120 if (LocaleCompare((const char *) tag,"crop") == 0)
2128 if (msl_info->image[n] == (Image *) NULL)
2130 ThrowMSLException(OptionError,"NoImagesDefined",
2131 (const char *) tag);
2134 SetGeometry(msl_info->image[n],&geometry);
2135 if (attributes != (const xmlChar **) NULL)
2136 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2138 keyword=(const char *) attributes[i++];
2139 attribute=InterpretImageProperties(msl_info->image_info[n],
2140 msl_info->attributes[n],(const char *) attributes[i]);
2141 CloneString(&value,attribute);
2147 if (LocaleCompare(keyword,"geometry") == 0)
2149 flags=ParsePageGeometry(msl_info->image[n],value,
2150 &geometry,&exception);
2151 if ((flags & HeightValue) == 0)
2152 geometry.height=geometry.width;
2155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2162 if (LocaleCompare(keyword,"height") == 0)
2164 geometry.height=StringToLong(value);
2167 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2174 if (LocaleCompare(keyword,"width") == 0)
2176 geometry.width=StringToLong(value);
2179 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2186 if (LocaleCompare(keyword,"x") == 0)
2188 geometry.x=StringToLong(value);
2191 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2198 if (LocaleCompare(keyword,"y") == 0)
2200 geometry.y=StringToLong(value);
2203 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2209 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2215 crop_image=CropImage(msl_info->image[n],&geometry,
2216 &msl_info->image[n]->exception);
2217 if (crop_image == (Image *) NULL)
2219 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2220 msl_info->image[n]=crop_image;
2223 if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
2229 Cycle-colormap image.
2231 if (msl_info->image[n] == (Image *) NULL)
2233 ThrowMSLException(OptionError,"NoImagesDefined",
2234 (const char *) tag);
2238 if (attributes != (const xmlChar **) NULL)
2239 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2241 keyword=(const char *) attributes[i++];
2242 attribute=InterpretImageProperties(msl_info->image_info[n],
2243 msl_info->attributes[n],(const char *) attributes[i]);
2244 CloneString(&value,attribute);
2250 if (LocaleCompare(keyword,"display") == 0)
2252 display=StringToLong(value);
2255 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2261 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2267 (void) CycleColormapImage(msl_info->image[n],display);
2270 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2275 if (LocaleCompare((const char *) tag,"despeckle") == 0)
2283 if (msl_info->image[n] == (Image *) NULL)
2285 ThrowMSLException(OptionError,"NoImagesDefined",
2286 (const char *) tag);
2289 if (attributes != (const xmlChar **) NULL)
2290 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2292 keyword=(const char *) attributes[i++];
2293 attribute=InterpretImageProperties(msl_info->image_info[n],
2294 msl_info->attributes[n],(const char *) attributes[i]);
2295 CloneString(&value,attribute);
2296 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2298 despeckle_image=DespeckleImage(msl_info->image[n],
2299 &msl_info->image[n]->exception);
2300 if (despeckle_image == (Image *) NULL)
2302 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2303 msl_info->image[n]=despeckle_image;
2306 if (LocaleCompare((const char *) tag,"display") == 0)
2308 if (msl_info->image[n] == (Image *) NULL)
2310 ThrowMSLException(OptionError,"NoImagesDefined",
2311 (const char *) tag);
2314 if (attributes != (const xmlChar **) NULL)
2315 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2317 keyword=(const char *) attributes[i++];
2318 attribute=InterpretImageProperties(msl_info->image_info[n],
2319 msl_info->attributes[n],(const char *) attributes[i]);
2320 CloneString(&value,attribute);
2325 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2331 (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
2334 if (LocaleCompare((const char *) tag,"draw") == 0)
2337 text[MaxTextExtent];
2342 if (msl_info->image[n] == (Image *) NULL)
2344 ThrowMSLException(OptionError,"NoImagesDefined",
2345 (const char *) tag);
2348 draw_info=CloneDrawInfo(msl_info->image_info[n],
2349 msl_info->draw_info[n]);
2351 current=draw_info->affine;
2352 GetAffineMatrix(&affine);
2353 if (attributes != (const xmlChar **) NULL)
2354 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2356 keyword=(const char *) attributes[i++];
2357 attribute=InterpretImageProperties(msl_info->image_info[n],
2358 msl_info->attributes[n],(const char *) attributes[i]);
2359 CloneString(&value,attribute);
2365 if (LocaleCompare(keyword,"affine") == 0)
2371 draw_info->affine.sx=strtod(p,&p);
2374 draw_info->affine.rx=strtod(p,&p);
2377 draw_info->affine.ry=strtod(p,&p);
2380 draw_info->affine.sy=strtod(p,&p);
2383 draw_info->affine.tx=strtod(p,&p);
2386 draw_info->affine.ty=strtod(p,&p);
2389 if (LocaleCompare(keyword,"align") == 0)
2391 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
2394 ThrowMSLException(OptionError,"UnrecognizedAlignType",
2396 draw_info->align=(AlignType) option;
2399 if (LocaleCompare(keyword,"antialias") == 0)
2401 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2404 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
2406 draw_info->stroke_antialias=(MagickBooleanType) option;
2407 draw_info->text_antialias=(MagickBooleanType) option;
2410 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2417 if (LocaleCompare(keyword,"density") == 0)
2419 CloneString(&draw_info->density,value);
2422 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2429 if (LocaleCompare(keyword,"encoding") == 0)
2431 CloneString(&draw_info->encoding,value);
2434 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2441 if (LocaleCompare(keyword, "fill") == 0)
2443 (void) QueryColorDatabase(value,&draw_info->fill,
2447 if (LocaleCompare(keyword,"family") == 0)
2449 CloneString(&draw_info->family,value);
2452 if (LocaleCompare(keyword,"font") == 0)
2454 CloneString(&draw_info->font,value);
2457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2464 if (LocaleCompare(keyword,"geometry") == 0)
2466 flags=ParsePageGeometry(msl_info->image[n],value,
2467 &geometry,&exception);
2468 if ((flags & HeightValue) == 0)
2469 geometry.height=geometry.width;
2472 if (LocaleCompare(keyword,"gravity") == 0)
2474 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
2477 ThrowMSLException(OptionError,"UnrecognizedGravityType",
2479 draw_info->gravity=(GravityType) option;
2482 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2489 if (LocaleCompare(keyword,"primitive") == 0)
2491 CloneString(&draw_info->primitive,value);
2494 if (LocaleCompare(keyword,"pointsize") == 0)
2496 draw_info->pointsize=StringToDouble(value);
2499 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2506 if (LocaleCompare(keyword,"rotate") == 0)
2508 angle=StringToDouble(value);
2509 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
2510 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
2511 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
2512 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
2515 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2522 if (LocaleCompare(keyword,"scale") == 0)
2524 flags=ParseGeometry(value,&geometry_info);
2525 if ((flags & SigmaValue) == 0)
2526 geometry_info.sigma=1.0;
2527 affine.sx=geometry_info.rho;
2528 affine.sy=geometry_info.sigma;
2531 if (LocaleCompare(keyword,"skewX") == 0)
2533 angle=StringToDouble(value);
2534 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
2537 if (LocaleCompare(keyword,"skewY") == 0)
2539 angle=StringToDouble(value);
2540 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
2543 if (LocaleCompare(keyword,"stretch") == 0)
2545 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
2548 ThrowMSLException(OptionError,"UnrecognizedStretchType",
2550 draw_info->stretch=(StretchType) option;
2553 if (LocaleCompare(keyword, "stroke") == 0)
2555 (void) QueryColorDatabase(value,&draw_info->stroke,
2559 if (LocaleCompare(keyword,"strokewidth") == 0)
2561 draw_info->stroke_width=StringToLong(value);
2564 if (LocaleCompare(keyword,"style") == 0)
2566 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
2569 ThrowMSLException(OptionError,"UnrecognizedStyleType",
2571 draw_info->style=(StyleType) option;
2574 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2581 if (LocaleCompare(keyword,"text") == 0)
2583 CloneString(&draw_info->text,value);
2586 if (LocaleCompare(keyword,"translate") == 0)
2588 flags=ParseGeometry(value,&geometry_info);
2589 if ((flags & SigmaValue) == 0)
2590 geometry_info.sigma=1.0;
2591 affine.tx=geometry_info.rho;
2592 affine.ty=geometry_info.sigma;
2595 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2602 if (LocaleCompare(keyword, "undercolor") == 0)
2604 (void) QueryColorDatabase(value,&draw_info->undercolor,
2608 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2615 if (LocaleCompare(keyword,"weight") == 0)
2617 draw_info->weight=StringToLong(value);
2620 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2627 if (LocaleCompare(keyword,"x") == 0)
2629 geometry.x=StringToLong(value);
2632 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2639 if (LocaleCompare(keyword,"y") == 0)
2641 geometry.y=StringToLong(value);
2644 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2650 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2656 (void) FormatMagickString(text,MaxTextExtent,
2657 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
2658 geometry.height,(double) geometry.x,(double) geometry.y);
2659 CloneString(&draw_info->geometry,text);
2660 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
2661 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
2662 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
2663 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
2664 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
2666 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
2668 (void) DrawImage(msl_info->image[n],draw_info);
2669 draw_info=DestroyDrawInfo(draw_info);
2672 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2677 if (LocaleCompare((const char *) tag,"edge") == 0)
2685 if (msl_info->image[n] == (Image *) NULL)
2687 ThrowMSLException(OptionError,"NoImagesDefined",
2688 (const char *) tag);
2691 if (attributes != (const xmlChar **) NULL)
2692 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2694 keyword=(const char *) attributes[i++];
2695 attribute=InterpretImageProperties(msl_info->image_info[n],
2696 msl_info->attributes[n],(const char *) attributes[i]);
2697 CloneString(&value,attribute);
2703 if (LocaleCompare(keyword,"geometry") == 0)
2705 flags=ParseGeometry(value,&geometry_info);
2706 if ((flags & SigmaValue) == 0)
2707 geometry_info.sigma=1.0;
2710 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2717 if (LocaleCompare(keyword,"radius") == 0)
2719 geometry_info.rho=StringToDouble(value);
2722 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2734 edge_image=EdgeImage(msl_info->image[n],geometry_info.rho,
2735 &msl_info->image[n]->exception);
2736 if (edge_image == (Image *) NULL)
2738 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2739 msl_info->image[n]=edge_image;
2742 if (LocaleCompare((const char *) tag,"emboss") == 0)
2750 if (msl_info->image[n] == (Image *) NULL)
2752 ThrowMSLException(OptionError,"NoImagesDefined",
2753 (const char *) tag);
2756 if (attributes != (const xmlChar **) NULL)
2757 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2759 keyword=(const char *) attributes[i++];
2760 attribute=InterpretImageProperties(msl_info->image_info[n],
2761 msl_info->attributes[n],(const char *) attributes[i]);
2762 CloneString(&value,attribute);
2768 if (LocaleCompare(keyword,"geometry") == 0)
2770 flags=ParseGeometry(value,&geometry_info);
2771 if ((flags & SigmaValue) == 0)
2772 geometry_info.sigma=1.0;
2775 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2782 if (LocaleCompare(keyword,"radius") == 0)
2784 geometry_info.rho=StringToDouble(value);
2787 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2794 if (LocaleCompare(keyword,"sigma") == 0)
2796 geometry_info.sigma=StringToLong(value);
2799 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2805 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2811 emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho,
2812 geometry_info.sigma,&msl_info->image[n]->exception);
2813 if (emboss_image == (Image *) NULL)
2815 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2816 msl_info->image[n]=emboss_image;
2819 if (LocaleCompare((const char *) tag,"enhance") == 0)
2827 if (msl_info->image[n] == (Image *) NULL)
2829 ThrowMSLException(OptionError,"NoImagesDefined",
2830 (const char *) tag);
2833 if (attributes != (const xmlChar **) NULL)
2834 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2836 keyword=(const char *) attributes[i++];
2837 attribute=InterpretImageProperties(msl_info->image_info[n],
2838 msl_info->attributes[n],(const char *) attributes[i]);
2839 CloneString(&value,attribute);
2840 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2842 enhance_image=EnhanceImage(msl_info->image[n],
2843 &msl_info->image[n]->exception);
2844 if (enhance_image == (Image *) NULL)
2846 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2847 msl_info->image[n]=enhance_image;
2850 if (LocaleCompare((const char *) tag,"equalize") == 0)
2855 if (msl_info->image[n] == (Image *) NULL)
2857 ThrowMSLException(OptionError,"NoImagesDefined",
2858 (const char *) tag);
2861 if (attributes != (const xmlChar **) NULL)
2862 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2864 keyword=(const char *) attributes[i++];
2865 attribute=InterpretImageProperties(msl_info->image_info[n],
2866 msl_info->attributes[n],(const char *) attributes[i]);
2867 CloneString(&value,attribute);
2872 ThrowMSLException(OptionError,"UnrecognizedAttribute",
2878 (void) EqualizeImage(msl_info->image[n]);
2881 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
2886 if (LocaleCompare((const char *) tag, "flatten") == 0)
2888 if (msl_info->image[n] == (Image *) NULL)
2890 ThrowMSLException(OptionError,"NoImagesDefined",
2891 (const char *) tag);
2895 /* no attributes here */
2897 /* process the image */
2902 newImage=MergeImageLayers(msl_info->image[n],FlattenLayer,
2903 &msl_info->image[n]->exception);
2904 if (newImage == (Image *) NULL)
2906 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2907 msl_info->image[n]=newImage;
2911 if (LocaleCompare((const char *) tag,"flip") == 0)
2919 if (msl_info->image[n] == (Image *) NULL)
2921 ThrowMSLException(OptionError,"NoImagesDefined",
2922 (const char *) tag);
2925 if (attributes != (const xmlChar **) NULL)
2926 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2928 keyword=(const char *) attributes[i++];
2929 attribute=InterpretImageProperties(msl_info->image_info[n],
2930 msl_info->attributes[n],(const char *) attributes[i]);
2931 CloneString(&value,attribute);
2932 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2934 flip_image=FlipImage(msl_info->image[n],
2935 &msl_info->image[n]->exception);
2936 if (flip_image == (Image *) NULL)
2938 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2939 msl_info->image[n]=flip_image;
2942 if (LocaleCompare((const char *) tag,"flop") == 0)
2950 if (msl_info->image[n] == (Image *) NULL)
2952 ThrowMSLException(OptionError,"NoImagesDefined",
2953 (const char *) tag);
2956 if (attributes != (const xmlChar **) NULL)
2957 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2959 keyword=(const char *) attributes[i++];
2960 attribute=InterpretImageProperties(msl_info->image_info[n],
2961 msl_info->attributes[n],(const char *) attributes[i]);
2962 CloneString(&value,attribute);
2963 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
2965 flop_image=FlopImage(msl_info->image[n],
2966 &msl_info->image[n]->exception);
2967 if (flop_image == (Image *) NULL)
2969 msl_info->image[n]=DestroyImage(msl_info->image[n]);
2970 msl_info->image[n]=flop_image;
2973 if (LocaleCompare((const char *) tag,"frame") == 0)
2984 if (msl_info->image[n] == (Image *) NULL)
2986 ThrowMSLException(OptionError,"NoImagesDefined",
2987 (const char *) tag);
2990 SetGeometry(msl_info->image[n],&geometry);
2991 if (attributes != (const xmlChar **) NULL)
2992 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
2994 keyword=(const char *) attributes[i++];
2995 attribute=InterpretImageProperties(msl_info->image_info[n],
2996 msl_info->attributes[n],(const char *) attributes[i]);
2997 CloneString(&value,attribute);
3003 if (LocaleCompare(keyword,"compose") == 0)
3005 option=ParseCommandOption(MagickComposeOptions,
3008 ThrowMSLException(OptionError,"UnrecognizedComposeType",
3010 msl_info->image[n]->compose=(CompositeOperator) option;
3013 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3020 if (LocaleCompare(keyword, "fill") == 0)
3022 (void) QueryColorDatabase(value,
3023 &msl_info->image[n]->matte_color,&exception);
3026 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3033 if (LocaleCompare(keyword,"geometry") == 0)
3035 flags=ParsePageGeometry(msl_info->image[n],value,
3036 &geometry,&exception);
3037 if ((flags & HeightValue) == 0)
3038 geometry.height=geometry.width;
3039 frame_info.width=geometry.width;
3040 frame_info.height=geometry.height;
3041 frame_info.outer_bevel=geometry.x;
3042 frame_info.inner_bevel=geometry.y;
3045 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3052 if (LocaleCompare(keyword,"height") == 0)
3054 frame_info.height=StringToLong(value);
3057 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3064 if (LocaleCompare(keyword,"inner") == 0)
3066 frame_info.inner_bevel=StringToLong(value);
3069 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3076 if (LocaleCompare(keyword,"outer") == 0)
3078 frame_info.outer_bevel=StringToLong(value);
3081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3088 if (LocaleCompare(keyword,"width") == 0)
3090 frame_info.width=StringToLong(value);
3093 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3099 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3105 frame_info.x=(ssize_t) frame_info.width;
3106 frame_info.y=(ssize_t) frame_info.height;
3107 frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
3108 frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
3109 frame_image=FrameImage(msl_info->image[n],&frame_info,
3110 &msl_info->image[n]->exception);
3111 if (frame_image == (Image *) NULL)
3113 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3114 msl_info->image[n]=frame_image;
3117 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3122 if (LocaleCompare((const char *) tag,"gamma") == 0)
3125 gamma[MaxTextExtent];
3133 if (msl_info->image[n] == (Image *) NULL)
3135 ThrowMSLException(OptionError,"NoImagesDefined",
3136 (const char *) tag);
3139 channel=UndefinedChannel;
3144 if (attributes != (const xmlChar **) NULL)
3145 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3147 keyword=(const char *) attributes[i++];
3148 attribute=InterpretImageProperties(msl_info->image_info[n],
3149 msl_info->attributes[n],(const char *) attributes[i]);
3150 CloneString(&value,attribute);
3156 if (LocaleCompare(keyword,"blue") == 0)
3158 pixel.blue=StringToDouble(value);
3161 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3168 if (LocaleCompare(keyword,"channel") == 0)
3170 option=ParseChannelOption(value);
3172 ThrowMSLException(OptionError,"UnrecognizedChannelType",
3174 channel=(ChannelType) option;
3177 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3184 if (LocaleCompare(keyword,"gamma") == 0)
3186 (void) CopyMagickString(gamma,value,MaxTextExtent);
3189 if (LocaleCompare(keyword,"green") == 0)
3191 pixel.green=StringToDouble(value);
3194 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3201 if (LocaleCompare(keyword,"red") == 0)
3203 pixel.red=StringToDouble(value);
3206 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3212 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3219 (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
3220 (double) pixel.red,(double) pixel.green,(double) pixel.blue);
3225 (void) GammaImage(msl_info->image[n],gamma);
3230 (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red);
3235 (void) GammaImageChannel(msl_info->image[n],GreenChannel,
3241 (void) GammaImageChannel(msl_info->image[n],BlueChannel,
3248 else if (LocaleCompare((const char *) tag,"get") == 0)
3250 if (msl_info->image[n] == (Image *) NULL)
3252 ThrowMSLException(OptionError,"NoImagesDefined",
3253 (const char *) tag);
3256 if (attributes == (const xmlChar **) NULL)
3258 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3260 keyword=(const char *) attributes[i++];
3261 CloneString(&value,(const char *) attributes[i]);
3262 (void) CopyMagickString(key,value,MaxTextExtent);
3268 if (LocaleCompare(keyword,"height") == 0)
3270 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3271 (double) msl_info->image[n]->rows);
3272 (void) SetImageProperty(msl_info->attributes[n],key,value);
3275 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3280 if (LocaleCompare(keyword,"width") == 0)
3282 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
3283 (double) msl_info->image[n]->columns);
3284 (void) SetImageProperty(msl_info->attributes[n],key,value);
3287 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3291 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3298 else if (LocaleCompare((const char *) tag, "group") == 0)
3300 msl_info->number_groups++;
3301 msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
3302 msl_info->group_info,msl_info->number_groups+1UL,
3303 sizeof(*msl_info->group_info));
3306 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3311 if (LocaleCompare((const char *) tag,"image") == 0)
3313 MSLPushImage(msl_info,(Image *) NULL);
3314 if (attributes == (const xmlChar **) NULL)
3316 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3318 keyword=(const char *) attributes[i++];
3319 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
3320 msl_info->attributes[n],(const char *) attributes[i]));
3326 if (LocaleCompare(keyword,"color") == 0)
3331 (void) CopyMagickString(msl_info->image_info[n]->filename,
3332 "xc:",MaxTextExtent);
3333 (void) ConcatenateMagickString(msl_info->image_info[n]->
3334 filename,value,MaxTextExtent);
3335 next_image=ReadImage(msl_info->image_info[n],&exception);
3336 CatchException(&exception);
3337 if (next_image == (Image *) NULL)
3339 if (msl_info->image[n] == (Image *) NULL)
3340 msl_info->image[n]=next_image;
3347 Link image into image list.
3349 p=msl_info->image[n];
3350 while (p->next != (Image *) NULL)
3351 p=GetNextImageInList(p);
3352 next_image->previous=p;
3357 (void) SetMSLAttributes(msl_info,keyword,value);
3362 (void) SetMSLAttributes(msl_info,keyword,value);
3369 if (LocaleCompare((const char *) tag,"implode") == 0)
3377 if (msl_info->image[n] == (Image *) NULL)
3379 ThrowMSLException(OptionError,"NoImagesDefined",
3380 (const char *) tag);
3383 if (attributes != (const xmlChar **) NULL)
3384 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3386 keyword=(const char *) attributes[i++];
3387 attribute=InterpretImageProperties(msl_info->image_info[n],
3388 msl_info->attributes[n],(const char *) attributes[i]);
3389 CloneString(&value,attribute);
3395 if (LocaleCompare(keyword,"amount") == 0)
3397 geometry_info.rho=StringToDouble(value);
3400 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3407 if (LocaleCompare(keyword,"geometry") == 0)
3409 flags=ParseGeometry(value,&geometry_info);
3410 if ((flags & SigmaValue) == 0)
3411 geometry_info.sigma=1.0;
3414 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3420 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3426 implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho,
3427 &msl_info->image[n]->exception);
3428 if (implode_image == (Image *) NULL)
3430 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3431 msl_info->image[n]=implode_image;
3434 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3439 if (LocaleCompare((const char *) tag,"label") == 0)
3441 if (LocaleCompare((const char *) tag, "level") == 0)
3444 levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
3446 if (msl_info->image[n] == (Image *) NULL)
3448 ThrowMSLException(OptionError,"NoImagesDefined",
3449 (const char *) tag);
3452 if (attributes == (const xmlChar **) NULL)
3454 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3456 keyword=(const char *) attributes[i++];
3457 CloneString(&value,(const char *) attributes[i]);
3458 (void) CopyMagickString(key,value,MaxTextExtent);
3464 if (LocaleCompare(keyword,"black") == 0)
3466 levelBlack = StringToDouble( value );
3469 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3475 if (LocaleCompare(keyword,"gamma") == 0)
3477 levelGamma = StringToDouble( value );
3480 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3486 if (LocaleCompare(keyword,"white") == 0)
3488 levelWhite = StringToDouble( value );
3491 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3496 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3504 char level[MaxTextExtent + 1];
3505 (void) FormatMagickString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",
3506 levelBlack,levelGamma,levelWhite);
3507 LevelImage ( msl_info->image[n], level );
3515 if (LocaleCompare((const char *) tag,"magnify") == 0)
3523 if (msl_info->image[n] == (Image *) NULL)
3525 ThrowMSLException(OptionError,"NoImagesDefined",
3526 (const char *) tag);
3529 if (attributes != (const xmlChar **) NULL)
3530 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3532 keyword=(const char *) attributes[i++];
3533 attribute=InterpretImageProperties(msl_info->image_info[n],
3534 msl_info->attributes[n],(const char *) attributes[i]);
3535 CloneString(&value,attribute);
3536 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3538 magnify_image=MagnifyImage(msl_info->image[n],
3539 &msl_info->image[n]->exception);
3540 if (magnify_image == (Image *) NULL)
3542 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3543 msl_info->image[n]=magnify_image;
3546 if (LocaleCompare((const char *) tag,"map") == 0)
3560 if (msl_info->image[n] == (Image *) NULL)
3562 ThrowMSLException(OptionError,"NoImagesDefined",
3563 (const char *) tag);
3566 affinity_image=NewImageList();
3568 if (attributes != (const xmlChar **) NULL)
3569 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3571 keyword=(const char *) attributes[i++];
3572 attribute=InterpretImageProperties(msl_info->image_info[n],
3573 msl_info->attributes[n],(const char *) attributes[i]);
3574 CloneString(&value,attribute);
3580 if (LocaleCompare(keyword,"dither") == 0)
3582 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
3585 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
3587 dither=(MagickBooleanType) option;
3590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3597 if (LocaleCompare(keyword,"image") == 0)
3598 for (j=0; j < msl_info->n; j++)
3603 attribute=GetImageProperty(msl_info->attributes[j],"id");
3604 if ((attribute != (const char *) NULL) &&
3605 (LocaleCompare(attribute,value) == 0))
3607 affinity_image=CloneImage(msl_info->image[j],0,0,
3608 MagickFalse,&exception);
3616 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3622 quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]);
3623 quantize_info->dither=dither;
3624 (void) RemapImages(quantize_info,msl_info->image[n],
3626 quantize_info=DestroyQuantizeInfo(quantize_info);
3627 affinity_image=DestroyImage(affinity_image);
3630 if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
3642 Matte floodfill image.
3645 if (msl_info->image[n] == (Image *) NULL)
3647 ThrowMSLException(OptionError,"NoImagesDefined",
3648 (const char *) tag);
3651 SetGeometry(msl_info->image[n],&geometry);
3652 paint_method=FloodfillMethod;
3653 if (attributes != (const xmlChar **) NULL)
3654 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3656 keyword=(const char *) attributes[i++];
3657 attribute=InterpretImageProperties(msl_info->image_info[n],
3658 msl_info->attributes[n],(const char *) attributes[i]);
3659 CloneString(&value,attribute);
3665 if (LocaleCompare(keyword,"bordercolor") == 0)
3667 (void) QueryMagickColor(value,&target,&exception);
3668 paint_method=FillToBorderMethod;
3671 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3678 if (LocaleCompare(keyword,"fuzz") == 0)
3680 msl_info->image[n]->fuzz=StringToDouble(value);
3683 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3690 if (LocaleCompare(keyword,"geometry") == 0)
3692 flags=ParsePageGeometry(msl_info->image[n],value,
3693 &geometry,&exception);
3694 if ((flags & HeightValue) == 0)
3695 geometry.height=geometry.width;
3696 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3697 geometry.x,geometry.y,&target,&exception);
3700 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3707 if (LocaleCompare(keyword,"opacity") == 0)
3709 opacity=StringToDouble(value);
3712 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3719 if (LocaleCompare(keyword,"x") == 0)
3721 geometry.x=StringToLong(value);
3722 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3723 geometry.x,geometry.y,&target,&exception);
3726 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3733 if (LocaleCompare(keyword,"y") == 0)
3735 geometry.y=StringToLong(value);
3736 (void) GetOneVirtualMagickPixel(msl_info->image[n],
3737 geometry.x,geometry.y,&target,&exception);
3740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3752 draw_info=CloneDrawInfo(msl_info->image_info[n],
3753 msl_info->draw_info[n]);
3754 draw_info->fill.opacity=ClampToQuantum(opacity);
3755 (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
3756 draw_info,&target,geometry.x,geometry.y,
3757 paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
3758 draw_info=DestroyDrawInfo(draw_info);
3761 if (LocaleCompare((const char *) tag,"median-filter") == 0)
3767 Median-filter image.
3769 if (msl_info->image[n] == (Image *) NULL)
3771 ThrowMSLException(OptionError,"NoImagesDefined",
3772 (const char *) tag);
3775 if (attributes != (const xmlChar **) NULL)
3776 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3778 keyword=(const char *) attributes[i++];
3779 attribute=InterpretImageProperties(msl_info->image_info[n],
3780 msl_info->attributes[n],(const char *) attributes[i]);
3781 CloneString(&value,attribute);
3787 if (LocaleCompare(keyword,"geometry") == 0)
3789 flags=ParseGeometry(value,&geometry_info);
3790 if ((flags & SigmaValue) == 0)
3791 geometry_info.sigma=1.0;
3794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3801 if (LocaleCompare(keyword,"radius") == 0)
3803 geometry_info.rho=StringToDouble(value);
3806 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3812 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3818 median_image=StatisticImage(msl_info->image[n],MedianStatistic,
3819 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
3820 &msl_info->image[n]->exception);
3821 if (median_image == (Image *) NULL)
3823 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3824 msl_info->image[n]=median_image;
3827 if (LocaleCompare((const char *) tag,"minify") == 0)
3835 if (msl_info->image[n] == (Image *) NULL)
3837 ThrowMSLException(OptionError,"NoImagesDefined",
3838 (const char *) tag);
3841 if (attributes != (const xmlChar **) NULL)
3842 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3844 keyword=(const char *) attributes[i++];
3845 attribute=InterpretImageProperties(msl_info->image_info[n],
3846 msl_info->attributes[n],(const char *) attributes[i]);
3847 CloneString(&value,attribute);
3848 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
3850 minify_image=MinifyImage(msl_info->image[n],
3851 &msl_info->image[n]->exception);
3852 if (minify_image == (Image *) NULL)
3854 msl_info->image[n]=DestroyImage(msl_info->image[n]);
3855 msl_info->image[n]=minify_image;
3858 if (LocaleCompare((const char *) tag,"msl") == 0 )
3860 if (LocaleCompare((const char *) tag,"modulate") == 0)
3863 modulate[MaxTextExtent];
3868 if (msl_info->image[n] == (Image *) NULL)
3870 ThrowMSLException(OptionError,"NoImagesDefined",
3871 (const char *) tag);
3874 geometry_info.rho=100.0;
3875 geometry_info.sigma=100.0;
3876 geometry_info.xi=100.0;
3877 if (attributes != (const xmlChar **) NULL)
3878 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3880 keyword=(const char *) attributes[i++];
3881 attribute=InterpretImageProperties(msl_info->image_info[n],
3882 msl_info->attributes[n],(const char *) attributes[i]);
3883 CloneString(&value,attribute);
3889 if (LocaleCompare(keyword,"blackness") == 0)
3891 geometry_info.rho=StringToDouble(value);
3894 if (LocaleCompare(keyword,"brightness") == 0)
3896 geometry_info.rho=StringToDouble(value);
3899 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3906 if (LocaleCompare(keyword,"factor") == 0)
3908 flags=ParseGeometry(value,&geometry_info);
3911 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3918 if (LocaleCompare(keyword,"hue") == 0)
3920 geometry_info.xi=StringToDouble(value);
3923 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3930 if (LocaleCompare(keyword,"lightness") == 0)
3932 geometry_info.rho=StringToDouble(value);
3935 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3942 if (LocaleCompare(keyword,"saturation") == 0)
3944 geometry_info.sigma=StringToDouble(value);
3947 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3954 if (LocaleCompare(keyword,"whiteness") == 0)
3956 geometry_info.sigma=StringToDouble(value);
3959 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3965 ThrowMSLException(OptionError,"UnrecognizedAttribute",
3971 (void) FormatMagickString(modulate,MaxTextExtent,"%g,%g,%g",
3972 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
3973 (void) ModulateImage(msl_info->image[n],modulate);
3976 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
3981 if (LocaleCompare((const char *) tag,"negate") == 0)
3989 if (msl_info->image[n] == (Image *) NULL)
3991 ThrowMSLException(OptionError,"NoImagesDefined",
3992 (const char *) tag);
3996 if (attributes != (const xmlChar **) NULL)
3997 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
3999 keyword=(const char *) attributes[i++];
4000 attribute=InterpretImageProperties(msl_info->image_info[n],
4001 msl_info->attributes[n],(const char *) attributes[i]);
4002 CloneString(&value,attribute);
4008 if (LocaleCompare(keyword,"channel") == 0)
4010 option=ParseChannelOption(value);
4012 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4014 channel=(ChannelType) option;
4017 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4024 if (LocaleCompare(keyword,"gray") == 0)
4026 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4029 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4031 gray=(MagickBooleanType) option;
4034 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4040 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4046 (void) NegateImageChannel(msl_info->image[n],channel,gray);
4049 if (LocaleCompare((const char *) tag,"normalize") == 0)
4054 if (msl_info->image[n] == (Image *) NULL)
4056 ThrowMSLException(OptionError,"NoImagesDefined",
4057 (const char *) tag);
4060 if (attributes != (const xmlChar **) NULL)
4061 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4063 keyword=(const char *) attributes[i++];
4064 attribute=InterpretImageProperties(msl_info->image_info[n],
4065 msl_info->attributes[n],(const char *) attributes[i]);
4066 CloneString(&value,attribute);
4072 if (LocaleCompare(keyword,"channel") == 0)
4074 option=ParseChannelOption(value);
4076 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4078 channel=(ChannelType) option;
4081 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4087 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4093 (void) NormalizeImageChannel(msl_info->image[n],channel);
4096 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4101 if (LocaleCompare((const char *) tag,"oil-paint") == 0)
4109 if (msl_info->image[n] == (Image *) NULL)
4111 ThrowMSLException(OptionError,"NoImagesDefined",
4112 (const char *) tag);
4115 if (attributes != (const xmlChar **) NULL)
4116 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4118 keyword=(const char *) attributes[i++];
4119 attribute=InterpretImageProperties(msl_info->image_info[n],
4120 msl_info->attributes[n],(const char *) attributes[i]);
4121 CloneString(&value,attribute);
4127 if (LocaleCompare(keyword,"geometry") == 0)
4129 flags=ParseGeometry(value,&geometry_info);
4130 if ((flags & SigmaValue) == 0)
4131 geometry_info.sigma=1.0;
4134 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4141 if (LocaleCompare(keyword,"radius") == 0)
4143 geometry_info.rho=StringToDouble(value);
4146 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4152 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4158 paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho,
4159 &msl_info->image[n]->exception);
4160 if (paint_image == (Image *) NULL)
4162 msl_info->image[n]=DestroyImage(msl_info->image[n]);
4163 msl_info->image[n]=paint_image;
4166 if (LocaleCompare((const char *) tag,"opaque") == 0)
4175 if (msl_info->image[n] == (Image *) NULL)
4177 ThrowMSLException(OptionError,"NoImagesDefined",
4178 (const char *) tag);
4181 (void) QueryMagickColor("none",&target,&exception);
4182 (void) QueryMagickColor("none",&fill_color,&exception);
4183 if (attributes != (const xmlChar **) NULL)
4184 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4186 keyword=(const char *) attributes[i++];
4187 attribute=InterpretImageProperties(msl_info->image_info[n],
4188 msl_info->attributes[n],(const char *) attributes[i]);
4189 CloneString(&value,attribute);
4195 if (LocaleCompare(keyword,"channel") == 0)
4197 option=ParseChannelOption(value);
4199 ThrowMSLException(OptionError,"UnrecognizedChannelType",
4201 channel=(ChannelType) option;
4204 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4211 if (LocaleCompare(keyword,"fill") == 0)
4213 (void) QueryMagickColor(value,&fill_color,&exception);
4216 if (LocaleCompare(keyword,"fuzz") == 0)
4218 msl_info->image[n]->fuzz=StringToDouble(value);
4221 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4227 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4233 (void) OpaquePaintImageChannel(msl_info->image[n],channel,
4234 &target,&fill_color,MagickFalse);
4237 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4242 if (LocaleCompare((const char *) tag,"print") == 0)
4244 if (attributes == (const xmlChar **) NULL)
4246 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4248 keyword=(const char *) attributes[i++];
4249 attribute=InterpretImageProperties(msl_info->image_info[n],
4250 msl_info->attributes[n],(const char *) attributes[i]);
4251 CloneString(&value,attribute);
4257 if (LocaleCompare(keyword,"output") == 0)
4259 (void) fprintf(stdout,"%s",value);
4262 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4267 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
4274 if (LocaleCompare((const char *) tag, "profile") == 0)
4276 if (msl_info->image[n] == (Image *) NULL)
4278 ThrowMSLException(OptionError,"NoImagesDefined",
4279 (const char *) tag);
4282 if (attributes == (const xmlChar **) NULL)
4284 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4298 keyword=(const char *) attributes[i++];
4299 attribute=InterpretImageProperties(msl_info->image_info[n],
4300 msl_info->attributes[n],(const char *) attributes[i]);
4301 CloneString(&value,attribute);
4302 if (*keyword == '+')
4305 Remove a profile from the image.
4307 (void) ProfileImage(msl_info->image[n],keyword,
4308 (const unsigned char *) NULL,0,MagickTrue);
4312 Associate a profile with the image.
4314 profile_info=CloneImageInfo(msl_info->image_info[n]);
4315 profile=GetImageProfile(msl_info->image[n],"iptc");
4316 if (profile != (StringInfo *) NULL)
4317 profile_info->profile=(void *) CloneStringInfo(profile);
4318 profile_image=GetImageCache(profile_info,keyword,&exception);
4319 profile_info=DestroyImageInfo(profile_info);
4320 if (profile_image == (Image *) NULL)
4323 name[MaxTextExtent],
4324 filename[MaxTextExtent];
4332 (void) CopyMagickString(filename,keyword,MaxTextExtent);
4333 (void) CopyMagickString(name,keyword,MaxTextExtent);
4334 for (p=filename; *p != '\0'; p++)
4335 if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
4336 (IsPathAccessible(keyword) == MagickFalse))
4342 Look for profile name (e.g. name:profile).
4344 (void) CopyMagickString(name,filename,(size_t)
4346 for (q=filename; *q != '\0'; q++)
4350 profile=FileToStringInfo(filename,~0UL,&exception);
4351 if (profile != (StringInfo *) NULL)
4353 (void) ProfileImage(msl_info->image[n],name,
4354 GetStringInfoDatum(profile),(size_t)
4355 GetStringInfoLength(profile),MagickFalse);
4356 profile=DestroyStringInfo(profile);
4360 ResetImageProfileIterator(profile_image);
4361 name=GetNextImageProfile(profile_image);
4362 while (name != (const char *) NULL)
4364 profile=GetImageProfile(profile_image,name);
4365 if (profile != (StringInfo *) NULL)
4366 (void) ProfileImage(msl_info->image[n],name,
4367 GetStringInfoDatum(profile),(size_t)
4368 GetStringInfoLength(profile),MagickFalse);
4369 name=GetNextImageProfile(profile_image);
4371 profile_image=DestroyImage(profile_image);
4375 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4380 if (LocaleCompare((const char *) tag,"quantize") == 0)
4388 if (msl_info->image[n] == (Image *) NULL)
4390 ThrowMSLException(OptionError,"NoImagesDefined",
4391 (const char *) tag);
4394 GetQuantizeInfo(&quantize_info);
4395 if (attributes != (const xmlChar **) NULL)
4396 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4398 keyword=(const char *) attributes[i++];
4399 attribute=InterpretImageProperties(msl_info->image_info[n],
4400 msl_info->attributes[n],(const char *) attributes[i]);
4401 CloneString(&value,attribute);
4407 if (LocaleCompare(keyword,"colors") == 0)
4409 quantize_info.number_colors=StringToLong(value);
4412 if (LocaleCompare(keyword,"colorspace") == 0)
4414 option=ParseCommandOption(MagickColorspaceOptions,
4417 ThrowMSLException(OptionError,
4418 "UnrecognizedColorspaceType",value);
4419 quantize_info.colorspace=(ColorspaceType) option;
4422 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4429 if (LocaleCompare(keyword,"dither") == 0)
4431 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4434 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4436 quantize_info.dither=(MagickBooleanType) option;
4439 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4446 if (LocaleCompare(keyword,"measure") == 0)
4448 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4451 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4453 quantize_info.measure_error=(MagickBooleanType) option;
4456 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4463 if (LocaleCompare(keyword,"treedepth") == 0)
4465 quantize_info.tree_depth=StringToLong(value);
4468 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4474 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4480 (void) QuantizeImage(&quantize_info,msl_info->image[n]);
4483 if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
4486 text[MaxTextExtent];
4497 draw_info=CloneDrawInfo(msl_info->image_info[n],
4498 msl_info->draw_info[n]);
4500 current=draw_info->affine;
4501 GetAffineMatrix(&affine);
4502 if (attributes != (const xmlChar **) NULL)
4503 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4505 keyword=(const char *) attributes[i++];
4506 attribute=InterpretImageProperties(msl_info->image_info[n],
4507 msl_info->attributes[n],(const char *) attributes[i]);
4508 CloneString(&value,attribute);
4514 if (LocaleCompare(keyword,"affine") == 0)
4520 draw_info->affine.sx=strtod(p,&p);
4523 draw_info->affine.rx=strtod(p,&p);
4526 draw_info->affine.ry=strtod(p,&p);
4529 draw_info->affine.sy=strtod(p,&p);
4532 draw_info->affine.tx=strtod(p,&p);
4535 draw_info->affine.ty=strtod(p,&p);
4538 if (LocaleCompare(keyword,"align") == 0)
4540 option=ParseCommandOption(MagickAlignOptions,MagickFalse,
4543 ThrowMSLException(OptionError,"UnrecognizedAlignType",
4545 draw_info->align=(AlignType) option;
4548 if (LocaleCompare(keyword,"antialias") == 0)
4550 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4553 ThrowMSLException(OptionError,"UnrecognizedBooleanType",
4555 draw_info->stroke_antialias=(MagickBooleanType) option;
4556 draw_info->text_antialias=(MagickBooleanType) option;
4559 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4566 if (LocaleCompare(keyword,"density") == 0)
4568 CloneString(&draw_info->density,value);
4571 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4578 if (LocaleCompare(keyword,"encoding") == 0)
4580 CloneString(&draw_info->encoding,value);
4583 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4590 if (LocaleCompare(keyword, "fill") == 0)
4592 (void) QueryColorDatabase(value,&draw_info->fill,
4596 if (LocaleCompare(keyword,"family") == 0)
4598 CloneString(&draw_info->family,value);
4601 if (LocaleCompare(keyword,"font") == 0)
4603 CloneString(&draw_info->font,value);
4606 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4613 if (LocaleCompare(keyword,"geometry") == 0)
4615 flags=ParsePageGeometry(msl_info->image[n],value,
4616 &geometry,&exception);
4617 if ((flags & HeightValue) == 0)
4618 geometry.height=geometry.width;
4621 if (LocaleCompare(keyword,"gravity") == 0)
4623 option=ParseCommandOption(MagickGravityOptions,MagickFalse,
4626 ThrowMSLException(OptionError,"UnrecognizedGravityType",
4628 draw_info->gravity=(GravityType) option;
4631 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(keyword,"pointsize") == 0)
4640 draw_info->pointsize=StringToDouble(value);
4643 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4650 if (LocaleCompare(keyword,"rotate") == 0)
4652 angle=StringToDouble(value);
4653 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
4654 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
4655 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
4656 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
4659 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4666 if (LocaleCompare(keyword,"scale") == 0)
4668 flags=ParseGeometry(value,&geometry_info);
4669 if ((flags & SigmaValue) == 0)
4670 geometry_info.sigma=1.0;
4671 affine.sx=geometry_info.rho;
4672 affine.sy=geometry_info.sigma;
4675 if (LocaleCompare(keyword,"skewX") == 0)
4677 angle=StringToDouble(value);
4678 affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
4681 if (LocaleCompare(keyword,"skewY") == 0)
4683 angle=StringToDouble(value);
4684 affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
4687 if (LocaleCompare(keyword,"stretch") == 0)
4689 option=ParseCommandOption(MagickStretchOptions,MagickFalse,
4692 ThrowMSLException(OptionError,"UnrecognizedStretchType",
4694 draw_info->stretch=(StretchType) option;
4697 if (LocaleCompare(keyword, "stroke") == 0)
4699 (void) QueryColorDatabase(value,&draw_info->stroke,
4703 if (LocaleCompare(keyword,"strokewidth") == 0)
4705 draw_info->stroke_width=StringToLong(value);
4708 if (LocaleCompare(keyword,"style") == 0)
4710 option=ParseCommandOption(MagickStyleOptions,MagickFalse,
4713 ThrowMSLException(OptionError,"UnrecognizedStyleType",
4715 draw_info->style=(StyleType) option;
4718 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4725 if (LocaleCompare(keyword,"text") == 0)
4727 CloneString(&draw_info->text,value);
4730 if (LocaleCompare(keyword,"translate") == 0)
4732 flags=ParseGeometry(value,&geometry_info);
4733 if ((flags & SigmaValue) == 0)
4734 geometry_info.sigma=1.0;
4735 affine.tx=geometry_info.rho;
4736 affine.ty=geometry_info.sigma;
4739 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(keyword, "undercolor") == 0)
4748 (void) QueryColorDatabase(value,&draw_info->undercolor,
4752 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4759 if (LocaleCompare(keyword,"weight") == 0)
4761 draw_info->weight=StringToLong(value);
4764 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4771 if (LocaleCompare(keyword,"x") == 0)
4773 geometry.x=StringToLong(value);
4776 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4783 if (LocaleCompare(keyword,"y") == 0)
4785 geometry.y=StringToLong(value);
4788 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4794 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4800 (void) FormatMagickString(text,MaxTextExtent,
4801 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
4802 geometry.height,(double) geometry.x,(double) geometry.y);
4803 CloneString(&draw_info->geometry,text);
4804 draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
4805 draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
4806 draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
4807 draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
4808 draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
4810 draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
4812 status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
4813 if (status != MagickFalse)
4818 image=msl_info->attributes[n];
4819 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
4820 "%g",metrics.pixels_per_em.x);
4821 FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
4822 "%g",metrics.pixels_per_em.y);
4823 FormatImageProperty(image,"msl:font-metrics.ascent","%g",
4825 FormatImageProperty(image,"msl:font-metrics.descent","%g",
4827 FormatImageProperty(image,"msl:font-metrics.width","%g",
4829 FormatImageProperty(image,"msl:font-metrics.height","%g",
4831 FormatImageProperty(image,"msl:font-metrics.max_advance","%g",
4832 metrics.max_advance);
4833 FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g",
4835 FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g",
4837 FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g",
4839 FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g",
4841 FormatImageProperty(image,"msl:font-metrics.origin.x","%g",
4843 FormatImageProperty(image,"msl:font-metrics.origin.y","%g",
4846 draw_info=DestroyDrawInfo(draw_info);
4849 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
4854 if (LocaleCompare((const char *) tag,"raise") == 0)
4862 if (msl_info->image[n] == (Image *) NULL)
4864 ThrowMSLException(OptionError,"NoImagesDefined",
4865 (const char *) tag);
4869 SetGeometry(msl_info->image[n],&geometry);
4870 if (attributes != (const xmlChar **) NULL)
4871 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4873 keyword=(const char *) attributes[i++];
4874 attribute=InterpretImageProperties(msl_info->image_info[n],
4875 msl_info->attributes[n],(const char *) attributes[i]);
4876 CloneString(&value,attribute);
4882 if (LocaleCompare(keyword,"geometry") == 0)
4884 flags=ParsePageGeometry(msl_info->image[n],value,
4885 &geometry,&exception);
4886 if ((flags & HeightValue) == 0)
4887 geometry.height=geometry.width;
4890 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4897 if (LocaleCompare(keyword,"height") == 0)
4899 geometry.height=StringToLong(value);
4902 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4909 if (LocaleCompare(keyword,"raise") == 0)
4911 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
4914 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
4916 raise=(MagickBooleanType) option;
4919 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4926 if (LocaleCompare(keyword,"width") == 0)
4928 geometry.width=StringToLong(value);
4931 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4937 ThrowMSLException(OptionError,"UnrecognizedAttribute",
4943 (void) RaiseImage(msl_info->image[n],&geometry,raise);
4946 if (LocaleCompare((const char *) tag,"read") == 0)
4948 if (attributes == (const xmlChar **) NULL)
4950 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
4952 keyword=(const char *) attributes[i++];
4953 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
4954 msl_info->attributes[n],(const char *) attributes[i]));
4960 if (LocaleCompare(keyword,"filename") == 0)
4965 (void) CopyMagickString(msl_info->image_info[n]->filename,
4966 value,MaxTextExtent);
4967 image=ReadImage(msl_info->image_info[n],&exception);
4968 CatchException(&exception);
4969 if (image == (Image *) NULL)
4971 AppendImageToList(&msl_info->image[n],image);
4974 (void) SetMSLAttributes(msl_info,keyword,value);
4979 (void) SetMSLAttributes(msl_info,keyword,value);
4986 if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
4994 if (msl_info->image[n] == (Image *) NULL)
4996 ThrowMSLException(OptionError,"NoImagesDefined",
4997 (const char *) tag);
5000 if (attributes != (const xmlChar **) NULL)
5001 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5003 keyword=(const char *) attributes[i++];
5004 attribute=InterpretImageProperties(msl_info->image_info[n],
5005 msl_info->attributes[n],(const char *) attributes[i]);
5006 CloneString(&value,attribute);
5012 if (LocaleCompare(keyword,"geometry") == 0)
5014 flags=ParseGeometry(value,&geometry_info);
5015 if ((flags & SigmaValue) == 0)
5016 geometry_info.sigma=1.0;
5019 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5026 if (LocaleCompare(keyword,"radius") == 0)
5028 geometry_info.rho=StringToDouble(value);
5031 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5037 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5043 paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic,
5044 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,
5045 &msl_info->image[n]->exception);
5046 if (paint_image == (Image *) NULL)
5048 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5049 msl_info->image[n]=paint_image;
5052 else if (LocaleCompare((const char *) tag,"repage") == 0)
5054 /* init the values */
5055 width=msl_info->image[n]->page.width;
5056 height=msl_info->image[n]->page.height;
5057 x=msl_info->image[n]->page.x;
5058 y=msl_info->image[n]->page.y;
5060 if (msl_info->image[n] == (Image *) NULL)
5062 ThrowMSLException(OptionError,"NoImagesDefined",
5063 (const char *) tag);
5066 if (attributes == (const xmlChar **) NULL)
5068 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5070 keyword=(const char *) attributes[i++];
5071 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5072 msl_info->attributes[n],(const char *) attributes[i]));
5078 if (LocaleCompare(keyword,"geometry") == 0)
5086 flags=ParseAbsoluteGeometry(value,&geometry);
5087 if ((flags & WidthValue) != 0)
5089 if ((flags & HeightValue) == 0)
5090 geometry.height=geometry.width;
5091 width=geometry.width;
5092 height=geometry.height;
5094 if ((flags & AspectValue) != 0)
5096 if ((flags & XValue) != 0)
5098 if ((flags & YValue) != 0)
5103 if ((flags & XValue) != 0)
5106 if ((width == 0) && (geometry.x > 0))
5107 width=msl_info->image[n]->columns+geometry.x;
5109 if ((flags & YValue) != 0)
5112 if ((height == 0) && (geometry.y > 0))
5113 height=msl_info->image[n]->rows+geometry.y;
5118 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5124 if (LocaleCompare(keyword,"height") == 0)
5126 height = StringToLong( value );
5129 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5135 if (LocaleCompare(keyword,"width") == 0)
5137 width = StringToLong( value );
5140 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5146 if (LocaleCompare(keyword,"x") == 0)
5148 x = StringToLong( value );
5151 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5157 if (LocaleCompare(keyword,"y") == 0)
5159 y = StringToLong( value );
5162 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5167 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5173 msl_info->image[n]->page.width=width;
5174 msl_info->image[n]->page.height=height;
5175 msl_info->image[n]->page.x=x;
5176 msl_info->image[n]->page.y=y;
5179 else if (LocaleCompare((const char *) tag,"resample") == 0)
5185 if (msl_info->image[n] == (Image *) NULL)
5187 ThrowMSLException(OptionError,"NoImagesDefined",
5188 (const char *) tag);
5191 if (attributes == (const xmlChar **) NULL)
5193 x_resolution=DefaultResolution;
5194 y_resolution=DefaultResolution;
5195 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5197 keyword=(const char *) attributes[i++];
5198 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5199 msl_info->attributes[n],(const char *) attributes[i]));
5204 if (LocaleCompare(keyword,"blur") == 0)
5206 msl_info->image[n]->blur=StringToDouble(value);
5209 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5215 if (LocaleCompare(keyword,"geometry") == 0)
5220 flags=ParseGeometry(value,&geometry_info);
5221 if ((flags & SigmaValue) == 0)
5222 geometry_info.sigma*=geometry_info.rho;
5223 x_resolution=geometry_info.rho;
5224 y_resolution=geometry_info.sigma;
5227 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5233 if (LocaleCompare(keyword,"x-resolution") == 0)
5235 x_resolution=StringToDouble(value);
5238 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5244 if (LocaleCompare(keyword,"y-resolution") == 0)
5246 y_resolution=StringToDouble(value);
5249 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5254 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5270 if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
5272 width=(size_t) (x_resolution*msl_info->image[n]->columns/
5273 (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
5274 msl_info->image[n]->x_resolution))+0.5);
5275 height=(size_t) (y_resolution*msl_info->image[n]->rows/
5276 (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
5277 msl_info->image[n]->y_resolution))+0.5);
5278 resample_image=ResizeImage(msl_info->image[n],width,height,
5279 msl_info->image[n]->filter,msl_info->image[n]->blur,
5280 &msl_info->image[n]->exception);
5281 if (resample_image == (Image *) NULL)
5283 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5284 msl_info->image[n]=resample_image;
5288 if (LocaleCompare((const char *) tag,"resize") == 0)
5302 if (msl_info->image[n] == (Image *) NULL)
5304 ThrowMSLException(OptionError,"NoImagesDefined",
5305 (const char *) tag);
5308 filter=UndefinedFilter;
5310 if (attributes != (const xmlChar **) NULL)
5311 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5313 keyword=(const char *) attributes[i++];
5314 attribute=InterpretImageProperties(msl_info->image_info[n],
5315 msl_info->attributes[n],(const char *) attributes[i]);
5316 CloneString(&value,attribute);
5322 if (LocaleCompare(keyword,"filter") == 0)
5324 option=ParseCommandOption(MagickFilterOptions,MagickFalse,
5327 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
5329 filter=(FilterTypes) option;
5332 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5339 if (LocaleCompare(keyword,"geometry") == 0)
5341 flags=ParseRegionGeometry(msl_info->image[n],value,
5342 &geometry,&exception);
5345 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5352 if (LocaleCompare(keyword,"height") == 0)
5354 geometry.height=StringToUnsignedLong(value);
5357 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5364 if (LocaleCompare(keyword,"support") == 0)
5366 blur=StringToDouble(value);
5369 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5376 if (LocaleCompare(keyword,"width") == 0)
5378 geometry.width=StringToLong(value);
5381 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5387 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5393 resize_image=ResizeImage(msl_info->image[n],geometry.width,
5394 geometry.height,filter,blur,&msl_info->image[n]->exception);
5395 if (resize_image == (Image *) NULL)
5397 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5398 msl_info->image[n]=resize_image;
5401 if (LocaleCompare((const char *) tag,"roll") == 0)
5409 if (msl_info->image[n] == (Image *) NULL)
5411 ThrowMSLException(OptionError,"NoImagesDefined",
5412 (const char *) tag);
5415 SetGeometry(msl_info->image[n],&geometry);
5416 if (attributes != (const xmlChar **) NULL)
5417 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5419 keyword=(const char *) attributes[i++];
5420 attribute=InterpretImageProperties(msl_info->image_info[n],
5421 msl_info->attributes[n],(const char *) attributes[i]);
5422 CloneString(&value,attribute);
5428 if (LocaleCompare(keyword,"geometry") == 0)
5430 flags=ParsePageGeometry(msl_info->image[n],value,
5431 &geometry,&exception);
5432 if ((flags & HeightValue) == 0)
5433 geometry.height=geometry.width;
5436 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5443 if (LocaleCompare(keyword,"x") == 0)
5445 geometry.x=StringToLong(value);
5448 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5455 if (LocaleCompare(keyword,"y") == 0)
5457 geometry.y=StringToLong(value);
5460 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5466 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5472 roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y,
5473 &msl_info->image[n]->exception);
5474 if (roll_image == (Image *) NULL)
5476 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5477 msl_info->image[n]=roll_image;
5480 else if (LocaleCompare((const char *) tag,"roll") == 0)
5482 /* init the values */
5483 width=msl_info->image[n]->columns;
5484 height=msl_info->image[n]->rows;
5487 if (msl_info->image[n] == (Image *) NULL)
5489 ThrowMSLException(OptionError,"NoImagesDefined",
5490 (const char *) tag);
5493 if (attributes == (const xmlChar **) NULL)
5495 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5497 keyword=(const char *) attributes[i++];
5498 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5499 msl_info->attributes[n],(const char *) attributes[i]));
5505 if (LocaleCompare(keyword,"geometry") == 0)
5507 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
5510 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5516 if (LocaleCompare(keyword,"x") == 0)
5518 x = StringToLong( value );
5521 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5527 if (LocaleCompare(keyword,"y") == 0)
5529 y = StringToLong( value );
5532 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5537 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5550 newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception);
5551 if (newImage == (Image *) NULL)
5553 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5554 msl_info->image[n]=newImage;
5559 if (LocaleCompare((const char *) tag,"rotate") == 0)
5567 if (msl_info->image[n] == (Image *) NULL)
5569 ThrowMSLException(OptionError,"NoImagesDefined",
5570 (const char *) tag);
5573 if (attributes != (const xmlChar **) NULL)
5574 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5576 keyword=(const char *) attributes[i++];
5577 attribute=InterpretImageProperties(msl_info->image_info[n],
5578 msl_info->attributes[n],(const char *) attributes[i]);
5579 CloneString(&value,attribute);
5585 if (LocaleCompare(keyword,"degrees") == 0)
5587 geometry_info.rho=StringToDouble(value);
5590 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5597 if (LocaleCompare(keyword,"geometry") == 0)
5599 flags=ParseGeometry(value,&geometry_info);
5600 if ((flags & SigmaValue) == 0)
5601 geometry_info.sigma=1.0;
5604 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5610 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5616 rotate_image=RotateImage(msl_info->image[n],geometry_info.rho,
5617 &msl_info->image[n]->exception);
5618 if (rotate_image == (Image *) NULL)
5620 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5621 msl_info->image[n]=rotate_image;
5624 else if (LocaleCompare((const char *) tag,"rotate") == 0)
5626 /* init the values */
5629 if (msl_info->image[n] == (Image *) NULL)
5631 ThrowMSLException(OptionError,"NoImagesDefined",
5632 (const char *) tag);
5635 if (attributes == (const xmlChar **) NULL)
5637 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5639 keyword=(const char *) attributes[i++];
5640 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5641 msl_info->attributes[n],(const char *) attributes[i]));
5647 if (LocaleCompare(keyword,"degrees") == 0)
5649 degrees = StringToDouble( value );
5652 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5657 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
5670 newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception);
5671 if (newImage == (Image *) NULL)
5673 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5674 msl_info->image[n]=newImage;
5679 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
5684 if (LocaleCompare((const char *) tag,"sample") == 0)
5692 if (msl_info->image[n] == (Image *) NULL)
5694 ThrowMSLException(OptionError,"NoImagesDefined",
5695 (const char *) tag);
5698 if (attributes != (const xmlChar **) NULL)
5699 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5701 keyword=(const char *) attributes[i++];
5702 attribute=InterpretImageProperties(msl_info->image_info[n],
5703 msl_info->attributes[n],(const char *) attributes[i]);
5704 CloneString(&value,attribute);
5710 if (LocaleCompare(keyword,"geometry") == 0)
5712 flags=ParseRegionGeometry(msl_info->image[n],value,
5713 &geometry,&exception);
5716 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5723 if (LocaleCompare(keyword,"height") == 0)
5725 geometry.height=StringToUnsignedLong(value);
5728 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5735 if (LocaleCompare(keyword,"width") == 0)
5737 geometry.width=StringToLong(value);
5740 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5746 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5752 sample_image=SampleImage(msl_info->image[n],geometry.width,
5753 geometry.height,&msl_info->image[n]->exception);
5754 if (sample_image == (Image *) NULL)
5756 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5757 msl_info->image[n]=sample_image;
5760 if (LocaleCompare((const char *) tag,"scale") == 0)
5768 if (msl_info->image[n] == (Image *) NULL)
5770 ThrowMSLException(OptionError,"NoImagesDefined",
5771 (const char *) tag);
5774 if (attributes != (const xmlChar **) NULL)
5775 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5777 keyword=(const char *) attributes[i++];
5778 attribute=InterpretImageProperties(msl_info->image_info[n],
5779 msl_info->attributes[n],(const char *) attributes[i]);
5780 CloneString(&value,attribute);
5786 if (LocaleCompare(keyword,"geometry") == 0)
5788 flags=ParseRegionGeometry(msl_info->image[n],value,
5789 &geometry,&exception);
5792 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5799 if (LocaleCompare(keyword,"height") == 0)
5801 geometry.height=StringToUnsignedLong(value);
5804 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5811 if (LocaleCompare(keyword,"width") == 0)
5813 geometry.width=StringToLong(value);
5816 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5822 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5828 scale_image=ScaleImage(msl_info->image[n],geometry.width,
5829 geometry.height,&msl_info->image[n]->exception);
5830 if (scale_image == (Image *) NULL)
5832 msl_info->image[n]=DestroyImage(msl_info->image[n]);
5833 msl_info->image[n]=scale_image;
5836 if (LocaleCompare((const char *) tag,"segment") == 0)
5847 if (msl_info->image[n] == (Image *) NULL)
5849 ThrowMSLException(OptionError,"NoImagesDefined",
5850 (const char *) tag);
5853 geometry_info.rho=1.0;
5854 geometry_info.sigma=1.5;
5855 colorspace=RGBColorspace;
5856 verbose=MagickFalse;
5857 if (attributes != (const xmlChar **) NULL)
5858 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5860 keyword=(const char *) attributes[i++];
5861 attribute=InterpretImageProperties(msl_info->image_info[n],
5862 msl_info->attributes[n],(const char *) attributes[i]);
5863 CloneString(&value,attribute);
5869 if (LocaleCompare(keyword,"cluster-threshold") == 0)
5871 geometry_info.rho=StringToDouble(value);
5874 if (LocaleCompare(keyword,"colorspace") == 0)
5876 option=ParseCommandOption(MagickColorspaceOptions,
5879 ThrowMSLException(OptionError,
5880 "UnrecognizedColorspaceType",value);
5881 colorspace=(ColorspaceType) option;
5884 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5891 if (LocaleCompare(keyword,"geometry") == 0)
5893 flags=ParseGeometry(value,&geometry_info);
5894 if ((flags & SigmaValue) == 0)
5895 geometry_info.sigma=1.5;
5898 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5905 if (LocaleCompare(keyword,"smoothing-threshold") == 0)
5907 geometry_info.sigma=StringToDouble(value);
5910 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5916 ThrowMSLException(OptionError,"UnrecognizedAttribute",
5922 (void) SegmentImage(msl_info->image[n],colorspace,verbose,
5923 geometry_info.rho,geometry_info.sigma);
5926 else if (LocaleCompare((const char *) tag, "set") == 0)
5928 if (msl_info->image[n] == (Image *) NULL)
5930 ThrowMSLException(OptionError,"NoImagesDefined",
5931 (const char *) tag);
5935 if (attributes == (const xmlChar **) NULL)
5937 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
5939 keyword=(const char *) attributes[i++];
5940 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
5941 msl_info->attributes[n],(const char *) attributes[i]));
5947 if (LocaleCompare(keyword,"clip-mask") == 0)
5949 for (j=0; j < msl_info->n; j++)
5954 property=GetImageProperty(msl_info->attributes[j],"id");
5955 if (LocaleCompare(property,value) == 0)
5957 SetImageMask(msl_info->image[n],msl_info->image[j]);
5963 if (LocaleCompare(keyword,"clip-path") == 0)
5965 for (j=0; j < msl_info->n; j++)
5970 property=GetImageProperty(msl_info->attributes[j],"id");
5971 if (LocaleCompare(property,value) == 0)
5973 SetImageClipMask(msl_info->image[n],msl_info->image[j]);
5979 if (LocaleCompare(keyword,"colorspace") == 0)
5984 colorspace=(ColorspaceType) ParseCommandOption(
5985 MagickColorspaceOptions,MagickFalse,value);
5987 ThrowMSLException(OptionError,"UnrecognizedColorspace",
5989 (void) TransformImageColorspace(msl_info->image[n],
5990 (ColorspaceType) colorspace);
5993 (void) SetMSLAttributes(msl_info,keyword,value);
5999 if (LocaleCompare(keyword,"density") == 0)
6001 flags=ParseGeometry(value,&geometry_info);
6002 msl_info->image[n]->x_resolution=geometry_info.rho;
6003 msl_info->image[n]->y_resolution=geometry_info.sigma;
6004 if ((flags & SigmaValue) == 0)
6005 msl_info->image[n]->y_resolution=
6006 msl_info->image[n]->x_resolution;
6009 (void) SetMSLAttributes(msl_info,keyword,value);
6015 if (LocaleCompare(keyword, "opacity") == 0)
6017 ssize_t opac = OpaqueOpacity,
6018 len = (ssize_t) strlen( value );
6020 if (value[len-1] == '%') {
6022 (void) CopyMagickString(tmp,value,len);
6023 opac = StringToLong( tmp );
6024 opac = (int)(QuantumRange * ((float)opac/100));
6026 opac = StringToLong( value );
6027 (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
6030 (void) SetMSLAttributes(msl_info,keyword,value);
6036 if (LocaleCompare(keyword, "page") == 0)
6039 page[MaxTextExtent];
6050 (void) ResetMagickMemory(&geometry,0,sizeof(geometry));
6051 image_option=GetImageOption(msl_info->image_info[n],"page");
6052 if (image_option != (const char *) NULL)
6053 flags=ParseAbsoluteGeometry(image_option,&geometry);
6054 flags=ParseAbsoluteGeometry(value,&geometry);
6055 (void) FormatMagickString(page,MaxTextExtent,"%.20gx%.20g",
6056 (double) geometry.width,(double) geometry.height);
6057 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
6058 (void) FormatMagickString(page,MaxTextExtent,
6059 "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
6060 (double) geometry.height,(double) geometry.x,(double)
6062 (void) SetImageOption(msl_info->image_info[n],keyword,page);
6063 msl_info->image_info[n]->page=GetPageGeometry(page);
6066 (void) SetMSLAttributes(msl_info,keyword,value);
6071 (void) SetMSLAttributes(msl_info,keyword,value);
6078 if (LocaleCompare((const char *) tag,"shade") == 0)
6089 if (msl_info->image[n] == (Image *) NULL)
6091 ThrowMSLException(OptionError,"NoImagesDefined",
6092 (const char *) tag);
6096 if (attributes != (const xmlChar **) NULL)
6097 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6099 keyword=(const char *) attributes[i++];
6100 attribute=InterpretImageProperties(msl_info->image_info[n],
6101 msl_info->attributes[n],(const char *) attributes[i]);
6102 CloneString(&value,attribute);
6108 if (LocaleCompare(keyword,"azimuth") == 0)
6110 geometry_info.rho=StringToDouble(value);
6113 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6120 if (LocaleCompare(keyword,"elevation") == 0)
6122 geometry_info.sigma=StringToDouble(value);
6125 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6132 if (LocaleCompare(keyword,"geometry") == 0)
6134 flags=ParseGeometry(value,&geometry_info);
6135 if ((flags & SigmaValue) == 0)
6136 geometry_info.sigma=1.0;
6139 if (LocaleCompare(keyword,"gray") == 0)
6141 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6144 ThrowMSLException(OptionError,"UnrecognizedNoiseType",
6146 gray=(MagickBooleanType) option;
6149 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6155 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6161 shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho,
6162 geometry_info.sigma,&msl_info->image[n]->exception);
6163 if (shade_image == (Image *) NULL)
6165 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6166 msl_info->image[n]=shade_image;
6169 if (LocaleCompare((const char *) tag,"shadow") == 0)
6177 if (msl_info->image[n] == (Image *) NULL)
6179 ThrowMSLException(OptionError,"NoImagesDefined",
6180 (const char *) tag);
6183 if (attributes != (const xmlChar **) NULL)
6184 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6186 keyword=(const char *) attributes[i++];
6187 attribute=InterpretImageProperties(msl_info->image_info[n],
6188 msl_info->attributes[n],(const char *) attributes[i]);
6189 CloneString(&value,attribute);
6195 if (LocaleCompare(keyword,"geometry") == 0)
6197 flags=ParseGeometry(value,&geometry_info);
6198 if ((flags & SigmaValue) == 0)
6199 geometry_info.sigma=1.0;
6202 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6209 if (LocaleCompare(keyword,"opacity") == 0)
6211 geometry_info.rho=StringToLong(value);
6214 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6221 if (LocaleCompare(keyword,"sigma") == 0)
6223 geometry_info.sigma=StringToLong(value);
6231 if (LocaleCompare(keyword,"x") == 0)
6233 geometry_info.xi=StringToDouble(value);
6236 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6243 if (LocaleCompare(keyword,"y") == 0)
6245 geometry_info.psi=StringToLong(value);
6248 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6254 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6260 shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
6261 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
6262 ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
6263 if (shadow_image == (Image *) NULL)
6265 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6266 msl_info->image[n]=shadow_image;
6269 if (LocaleCompare((const char *) tag,"sharpen") == 0)
6271 double radius = 0.0,
6274 if (msl_info->image[n] == (Image *) NULL)
6276 ThrowMSLException(OptionError,"NoImagesDefined",
6277 (const char *) tag);
6281 NOTE: sharpen can have no attributes, since we use all the defaults!
6283 if (attributes != (const xmlChar **) NULL)
6285 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6287 keyword=(const char *) attributes[i++];
6288 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6289 msl_info->attributes[n],(const char *) attributes[i]));
6295 if (LocaleCompare(keyword, "radius") == 0)
6297 radius = StringToDouble( value );
6300 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6306 if (LocaleCompare(keyword,"sigma") == 0)
6308 sigma = StringToLong( value );
6311 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6316 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6330 newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception);
6331 if (newImage == (Image *) NULL)
6333 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6334 msl_info->image[n]=newImage;
6338 else if (LocaleCompare((const char *) tag,"shave") == 0)
6340 /* init the values */
6344 if (msl_info->image[n] == (Image *) NULL)
6346 ThrowMSLException(OptionError,"NoImagesDefined",
6347 (const char *) tag);
6350 if (attributes == (const xmlChar **) NULL)
6352 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6354 keyword=(const char *) attributes[i++];
6355 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6356 msl_info->attributes[n],(const char *) attributes[i]));
6362 if (LocaleCompare(keyword,"geometry") == 0)
6364 (void) ParseMetaGeometry(value,&x,&y,&width,&height);
6367 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6373 if (LocaleCompare(keyword,"height") == 0)
6375 height = StringToLong( value );
6378 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6384 if (LocaleCompare(keyword,"width") == 0)
6386 width = StringToLong( value );
6389 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6394 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6409 rectInfo.height = height;
6410 rectInfo.width = width;
6415 newImage=ShaveImage(msl_info->image[n], &rectInfo,
6416 &msl_info->image[n]->exception);
6417 if (newImage == (Image *) NULL)
6419 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6420 msl_info->image[n]=newImage;
6425 if (LocaleCompare((const char *) tag,"shear") == 0)
6433 if (msl_info->image[n] == (Image *) NULL)
6435 ThrowMSLException(OptionError,"NoImagesDefined",
6436 (const char *) tag);
6439 if (attributes != (const xmlChar **) NULL)
6440 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6442 keyword=(const char *) attributes[i++];
6443 attribute=InterpretImageProperties(msl_info->image_info[n],
6444 msl_info->attributes[n],(const char *) attributes[i]);
6445 CloneString(&value,attribute);
6451 if (LocaleCompare(keyword, "fill") == 0)
6453 (void) QueryColorDatabase(value,
6454 &msl_info->image[n]->background_color,&exception);
6457 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6464 if (LocaleCompare(keyword,"geometry") == 0)
6466 flags=ParseGeometry(value,&geometry_info);
6467 if ((flags & SigmaValue) == 0)
6468 geometry_info.sigma=1.0;
6471 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6478 if (LocaleCompare(keyword,"x") == 0)
6480 geometry_info.rho=StringToDouble(value);
6483 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6490 if (LocaleCompare(keyword,"y") == 0)
6492 geometry_info.sigma=StringToLong(value);
6495 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6501 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6507 shear_image=ShearImage(msl_info->image[n],geometry_info.rho,
6508 geometry_info.sigma,&msl_info->image[n]->exception);
6509 if (shear_image == (Image *) NULL)
6511 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6512 msl_info->image[n]=shear_image;
6515 if (LocaleCompare((const char *) tag,"signature") == 0)
6520 if (msl_info->image[n] == (Image *) NULL)
6522 ThrowMSLException(OptionError,"NoImagesDefined",
6523 (const char *) tag);
6526 if (attributes != (const xmlChar **) NULL)
6527 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6529 keyword=(const char *) attributes[i++];
6530 attribute=InterpretImageProperties(msl_info->image_info[n],
6531 msl_info->attributes[n],(const char *) attributes[i]);
6532 CloneString(&value,attribute);
6537 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6543 (void) SignatureImage(msl_info->image[n]);
6546 if (LocaleCompare((const char *) tag,"solarize") == 0)
6551 if (msl_info->image[n] == (Image *) NULL)
6553 ThrowMSLException(OptionError,"NoImagesDefined",
6554 (const char *) tag);
6557 geometry_info.rho=QuantumRange/2.0;
6558 if (attributes != (const xmlChar **) NULL)
6559 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6561 keyword=(const char *) attributes[i++];
6562 attribute=InterpretImageProperties(msl_info->image_info[n],
6563 msl_info->attributes[n],(const char *) attributes[i]);
6564 CloneString(&value,attribute);
6570 if (LocaleCompare(keyword,"geometry") == 0)
6572 flags=ParseGeometry(value,&geometry_info);
6575 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6582 if (LocaleCompare(keyword,"threshold") == 0)
6584 geometry_info.rho=StringToDouble(value);
6587 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6593 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6599 (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
6602 if (LocaleCompare((const char *) tag,"spread") == 0)
6610 if (msl_info->image[n] == (Image *) NULL)
6612 ThrowMSLException(OptionError,"NoImagesDefined",
6613 (const char *) tag);
6616 if (attributes != (const xmlChar **) NULL)
6617 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6619 keyword=(const char *) attributes[i++];
6620 attribute=InterpretImageProperties(msl_info->image_info[n],
6621 msl_info->attributes[n],(const char *) attributes[i]);
6622 CloneString(&value,attribute);
6628 if (LocaleCompare(keyword,"geometry") == 0)
6630 flags=ParseGeometry(value,&geometry_info);
6631 if ((flags & SigmaValue) == 0)
6632 geometry_info.sigma=1.0;
6635 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6642 if (LocaleCompare(keyword,"radius") == 0)
6644 geometry_info.rho=StringToDouble(value);
6647 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6653 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6659 spread_image=SpreadImage(msl_info->image[n],geometry_info.rho,
6660 &msl_info->image[n]->exception);
6661 if (spread_image == (Image *) NULL)
6663 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6664 msl_info->image[n]=spread_image;
6667 else if (LocaleCompare((const char *) tag,"stegano") == 0)
6670 watermark = (Image*)NULL;
6672 if (msl_info->image[n] == (Image *) NULL)
6674 ThrowMSLException(OptionError,"NoImagesDefined",
6675 (const char *) tag);
6678 if (attributes == (const xmlChar **) NULL)
6680 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6682 keyword=(const char *) attributes[i++];
6683 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6684 msl_info->attributes[n],(const char *) attributes[i]));
6690 if (LocaleCompare(keyword,"image") == 0)
6692 for (j=0; j<msl_info->n;j++)
6695 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6696 if (theAttr && LocaleCompare(theAttr, value) == 0)
6698 watermark = msl_info->image[j];
6704 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6709 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6718 if ( watermark != (Image*) NULL )
6723 newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception);
6724 if (newImage == (Image *) NULL)
6726 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6727 msl_info->image[n]=newImage;
6730 ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
6732 else if (LocaleCompare((const char *) tag,"stereo") == 0)
6735 stereoImage = (Image*)NULL;
6737 if (msl_info->image[n] == (Image *) NULL)
6739 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
6742 if (attributes == (const xmlChar **) NULL)
6744 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6746 keyword=(const char *) attributes[i++];
6747 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
6748 msl_info->attributes[n],(const char *) attributes[i]));
6754 if (LocaleCompare(keyword,"image") == 0)
6756 for (j=0; j<msl_info->n;j++)
6759 theAttr = GetImageProperty(msl_info->attributes[j], "id");
6760 if (theAttr && LocaleCompare(theAttr, value) == 0)
6762 stereoImage = msl_info->image[j];
6768 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6773 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
6782 if ( stereoImage != (Image*) NULL )
6787 newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception);
6788 if (newImage == (Image *) NULL)
6790 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6791 msl_info->image[n]=newImage;
6794 ThrowMSLException(OptionError,"Missing stereo image",keyword);
6796 if (LocaleCompare((const char *) tag,"swap") == 0)
6807 if (msl_info->image[n] == (Image *) NULL)
6809 ThrowMSLException(OptionError,"NoImagesDefined",
6810 (const char *) tag);
6815 if (attributes != (const xmlChar **) NULL)
6816 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6818 keyword=(const char *) attributes[i++];
6819 attribute=InterpretImageProperties(msl_info->image_info[n],
6820 msl_info->attributes[n],(const char *) attributes[i]);
6821 CloneString(&value,attribute);
6827 if (LocaleCompare(keyword,"indexes") == 0)
6829 flags=ParseGeometry(value,&geometry_info);
6830 index=(ssize_t) geometry_info.rho;
6831 if ((flags & SigmaValue) == 0)
6832 swap_index=(ssize_t) geometry_info.sigma;
6835 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6841 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6850 p=GetImageFromList(msl_info->image[n],index);
6851 q=GetImageFromList(msl_info->image[n],swap_index);
6852 if ((p == (Image *) NULL) || (q == (Image *) NULL))
6854 ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
6857 swap=CloneImage(p,0,0,MagickTrue,&p->exception);
6858 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception));
6859 ReplaceImageInList(&q,swap);
6860 msl_info->image[n]=GetFirstImageInList(q);
6863 if (LocaleCompare((const char *) tag,"swirl") == 0)
6871 if (msl_info->image[n] == (Image *) NULL)
6873 ThrowMSLException(OptionError,"NoImagesDefined",
6874 (const char *) tag);
6877 if (attributes != (const xmlChar **) NULL)
6878 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6880 keyword=(const char *) attributes[i++];
6881 attribute=InterpretImageProperties(msl_info->image_info[n],
6882 msl_info->attributes[n],(const char *) attributes[i]);
6883 CloneString(&value,attribute);
6889 if (LocaleCompare(keyword,"degrees") == 0)
6891 geometry_info.rho=StringToDouble(value);
6894 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6901 if (LocaleCompare(keyword,"geometry") == 0)
6903 flags=ParseGeometry(value,&geometry_info);
6904 if ((flags & SigmaValue) == 0)
6905 geometry_info.sigma=1.0;
6908 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6914 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6920 swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho,
6921 &msl_info->image[n]->exception);
6922 if (swirl_image == (Image *) NULL)
6924 msl_info->image[n]=DestroyImage(msl_info->image[n]);
6925 msl_info->image[n]=swirl_image;
6928 if (LocaleCompare((const char *) tag,"sync") == 0)
6933 if (msl_info->image[n] == (Image *) NULL)
6935 ThrowMSLException(OptionError,"NoImagesDefined",
6936 (const char *) tag);
6939 if (attributes != (const xmlChar **) NULL)
6940 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6942 keyword=(const char *) attributes[i++];
6943 attribute=InterpretImageProperties(msl_info->image_info[n],
6944 msl_info->attributes[n],(const char *) attributes[i]);
6945 CloneString(&value,attribute);
6950 ThrowMSLException(OptionError,"UnrecognizedAttribute",
6956 (void) SyncImage(msl_info->image[n]);
6959 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
6964 if (LocaleCompare((const char *) tag,"map") == 0)
6972 if (msl_info->image[n] == (Image *) NULL)
6974 ThrowMSLException(OptionError,"NoImagesDefined",
6975 (const char *) tag);
6978 texture_image=NewImageList();
6979 if (attributes != (const xmlChar **) NULL)
6980 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
6982 keyword=(const char *) attributes[i++];
6983 attribute=InterpretImageProperties(msl_info->image_info[n],
6984 msl_info->attributes[n],(const char *) attributes[i]);
6985 CloneString(&value,attribute);
6991 if (LocaleCompare(keyword,"image") == 0)
6992 for (j=0; j < msl_info->n; j++)
6997 attribute=GetImageProperty(msl_info->attributes[j],"id");
6998 if ((attribute != (const char *) NULL) &&
6999 (LocaleCompare(attribute,value) == 0))
7001 texture_image=CloneImage(msl_info->image[j],0,0,
7002 MagickFalse,&exception);
7010 ThrowMSLException(OptionError,"UnrecognizedAttribute",
7016 (void) TextureImage(msl_info->image[n],texture_image);
7017 texture_image=DestroyImage(texture_image);
7020 else if (LocaleCompare((const char *) tag,"threshold") == 0)
7022 /* init the values */
7023 double threshold = 0;
7025 if (msl_info->image[n] == (Image *) NULL)
7027 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7030 if (attributes == (const xmlChar **) NULL)
7032 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7034 keyword=(const char *) attributes[i++];
7035 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7036 msl_info->attributes[n],(const char *) attributes[i]));
7042 if (LocaleCompare(keyword,"threshold") == 0)
7044 threshold = StringToDouble( value );
7047 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7052 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7062 BilevelImageChannel(msl_info->image[n],
7063 (ChannelType) ((ssize_t) (CompositeChannels &~ (ssize_t) OpacityChannel)),
7068 else if (LocaleCompare((const char *) tag, "transparent") == 0)
7070 if (msl_info->image[n] == (Image *) NULL)
7072 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7075 if (attributes == (const xmlChar **) NULL)
7077 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7079 keyword=(const char *) attributes[i++];
7080 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7081 msl_info->attributes[n],(const char *) attributes[i]));
7087 if (LocaleCompare(keyword,"color") == 0)
7092 (void) QueryMagickColor(value,&target,&exception);
7093 (void) TransparentPaintImage(msl_info->image[n],&target,
7094 TransparentOpacity,MagickFalse);
7097 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7102 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7109 else if (LocaleCompare((const char *) tag, "trim") == 0)
7111 if (msl_info->image[n] == (Image *) NULL)
7113 ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
7117 /* no attributes here */
7119 /* process the image */
7126 /* all zeros on a crop == trim edges! */
7127 rectInfo.height = rectInfo.width = 0;
7128 rectInfo.x = rectInfo.y = 0;
7130 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception);
7131 if (newImage == (Image *) NULL)
7133 msl_info->image[n]=DestroyImage(msl_info->image[n]);
7134 msl_info->image[n]=newImage;
7138 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7143 if (LocaleCompare((const char *) tag,"write") == 0)
7145 if (msl_info->image[n] == (Image *) NULL)
7147 ThrowMSLException(OptionError,"NoImagesDefined",
7148 (const char *) tag);
7151 if (attributes == (const xmlChar **) NULL)
7153 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
7155 keyword=(const char *) attributes[i++];
7156 CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
7157 msl_info->attributes[n],(const char *) attributes[i]));
7163 if (LocaleCompare(keyword,"filename") == 0)
7165 (void) CopyMagickString(msl_info->image[n]->filename,value,
7169 (void) SetMSLAttributes(msl_info,keyword,value);
7173 (void) SetMSLAttributes(msl_info,keyword,value);
7181 (void) WriteImage(msl_info->image_info[n], msl_info->image[n]);
7185 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7189 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
7193 if ( value != NULL )
7194 value=DestroyString(value);
7195 (void) LogMagickEvent(CoderEvent,GetMagickModule()," )");
7198 static void MSLEndElement(void *context,const xmlChar *tag)
7207 Called when the end of an element has been detected.
7209 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endElement(%s)",
7211 msl_info=(MSLInfo *) context;
7218 if (LocaleCompare((const char *) tag,"comment") == 0 )
7220 (void) DeleteImageProperty(msl_info->image[n],"comment");
7221 if (msl_info->content == (char *) NULL)
7223 StripString(msl_info->content);
7224 (void) SetImageProperty(msl_info->image[n],"comment",
7233 if (LocaleCompare((const char *) tag, "group") == 0 )
7235 if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
7237 ssize_t i = (ssize_t)
7238 (msl_info->group_info[msl_info->number_groups-1].numImages);
7241 if (msl_info->image[msl_info->n] != (Image *) NULL)
7242 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]);
7243 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]);
7244 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]);
7248 msl_info->number_groups--;
7255 if (LocaleCompare((const char *) tag, "image") == 0)
7256 MSLPopImage(msl_info);
7262 if (LocaleCompare((const char *) tag,"label") == 0 )
7264 (void) DeleteImageProperty(msl_info->image[n],"label");
7265 if (msl_info->content == (char *) NULL)
7267 StripString(msl_info->content);
7268 (void) SetImageProperty(msl_info->image[n],"label",
7277 if (LocaleCompare((const char *) tag, "msl") == 0 )
7280 This our base element.
7281 at the moment we don't do anything special
7282 but someday we might!
7290 if (msl_info->content != (char *) NULL)
7291 msl_info->content=DestroyString(msl_info->content);
7294 static void MSLCharacters(void *context,const xmlChar *c,int length)
7306 Receiving some characters from the parser.
7308 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7309 " SAX.characters(%s,%d)",c,length);
7310 msl_info=(MSLInfo *) context;
7311 if (msl_info->content != (char *) NULL)
7312 msl_info->content=(char *) ResizeQuantumMemory(msl_info->content,
7313 strlen(msl_info->content)+length+MaxTextExtent,
7314 sizeof(*msl_info->content));
7317 msl_info->content=(char *) NULL;
7318 if (~length >= MaxTextExtent)
7319 msl_info->content=(char *) AcquireQuantumMemory(length+MaxTextExtent,
7320 sizeof(*msl_info->content));
7321 if (msl_info->content != (char *) NULL)
7322 *msl_info->content='\0';
7324 if (msl_info->content == (char *) NULL)
7326 p=msl_info->content+strlen(msl_info->content);
7327 for (i=0; i < length; i++)
7332 static void MSLReference(void *context,const xmlChar *name)
7341 Called when an entity reference is detected.
7343 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7344 " SAX.reference(%s)",name);
7345 msl_info=(MSLInfo *) context;
7346 parser=msl_info->parser;
7348 (void) xmlAddChild(parser->node,xmlNewCharRef(msl_info->document,name));
7350 (void) xmlAddChild(parser->node,xmlNewReference(msl_info->document,name));
7353 static void MSLIgnorableWhitespace(void *context,const xmlChar *c,int length)
7359 Receiving some ignorable whitespaces from the parser.
7361 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7362 " SAX.ignorableWhitespace(%.30s, %d)",c,length);
7363 msl_info=(MSLInfo *) context;
7367 static void MSLProcessingInstructions(void *context,const xmlChar *target,
7368 const xmlChar *data)
7374 A processing instruction has been parsed.
7376 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7377 " SAX.processingInstruction(%s, %s)",
7379 msl_info=(MSLInfo *) context;
7383 static void MSLComment(void *context,const xmlChar *value)
7389 A comment has been parsed.
7391 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7392 " SAX.comment(%s)",value);
7393 msl_info=(MSLInfo *) context;
7397 static void MSLWarning(void *context,const char *format,...)
7401 reason[MaxTextExtent];
7410 Display and format a warning messages, gives file, line, position and
7413 va_start(operands,format);
7414 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.warning: ");
7415 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7416 msl_info=(MSLInfo *) context;
7418 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7419 (void) vsprintf(reason,format,operands);
7421 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7423 message=GetExceptionMessage(errno);
7424 ThrowMSLException(CoderError,reason,message);
7425 message=DestroyString(message);
7429 static void MSLError(void *context,const char *format,...)
7432 reason[MaxTextExtent];
7441 Display and format a error formats, gives file, line, position and
7444 va_start(operands,format);
7445 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.error: ");
7446 (void) LogMagickEvent(CoderEvent,GetMagickModule(),format,operands);
7447 msl_info=(MSLInfo *) context;
7449 #if !defined(MAGICKCORE_HAVE_VSNPRINTF)
7450 (void) vsprintf(reason,format,operands);
7452 (void) vsnprintf(reason,MaxTextExtent,format,operands);
7454 ThrowMSLException(DelegateFatalError,reason,"SAX error");
7458 static void MSLCDataBlock(void *context,const xmlChar *value,int length)
7470 Called when a pcdata block has been parsed.
7472 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7473 " SAX.pcdata(%s, %d)",value,length);
7474 msl_info=(MSLInfo *) context;
7476 parser=msl_info->parser;
7477 child=xmlGetLastChild(parser->node);
7478 if ((child != (xmlNodePtr) NULL) && (child->type == XML_CDATA_SECTION_NODE))
7480 xmlTextConcat(child,value,length);
7483 (void) xmlAddChild(parser->node,xmlNewCDataBlock(parser->myDoc,value,length));
7486 static void MSLExternalSubset(void *context,const xmlChar *name,
7487 const xmlChar *external_id,const xmlChar *system_id)
7502 Does this document has an external subset?
7504 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
7505 " SAX.externalSubset(%s %s %s)",name,
7506 (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
7507 (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
7508 msl_info=(MSLInfo *) context;
7510 parser=msl_info->parser;
7511 if (((external_id == NULL) && (system_id == NULL)) ||
7512 ((parser->validate == 0) || (parser->wellFormed == 0) ||
7513 (msl_info->document == 0)))
7515 input=MSLResolveEntity(context,external_id,system_id);
7518 (void) xmlNewDtd(msl_info->document,name,external_id,system_id);
7519 parser_context=(*parser);
7520 parser->inputTab=(xmlParserInputPtr *) xmlMalloc(5*sizeof(*parser->inputTab));
7521 if (parser->inputTab == (xmlParserInputPtr *) NULL)
7523 parser->errNo=XML_ERR_NO_MEMORY;
7524 parser->input=parser_context.input;
7525 parser->inputNr=parser_context.inputNr;
7526 parser->inputMax=parser_context.inputMax;
7527 parser->inputTab=parser_context.inputTab;
7533 xmlPushInput(parser,input);
7534 (void) xmlSwitchEncoding(parser,xmlDetectCharEncoding(parser->input->cur,4));
7535 if (input->filename == (char *) NULL)
7536 input->filename=(char *) xmlStrdup(system_id);
7539 input->base=parser->input->cur;
7540 input->cur=parser->input->cur;
7542 xmlParseExternalSubset(parser,external_id,system_id);
7543 while (parser->inputNr > 1)
7544 (void) xmlPopInput(parser);
7545 xmlFreeInputStream(parser->input);
7546 xmlFree(parser->inputTab);
7547 parser->input=parser_context.input;
7548 parser->inputNr=parser_context.inputNr;
7549 parser->inputMax=parser_context.inputMax;
7550 parser->inputTab=parser_context.inputTab;
7553 #if defined(__cplusplus) || defined(c_plusplus)
7557 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
7558 ExceptionInfo *exception)
7561 message[MaxTextExtent];
7584 assert(image_info != (const ImageInfo *) NULL);
7585 assert(image_info->signature == MagickSignature);
7586 if (image_info->debug != MagickFalse)
7587 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
7588 image_info->filename);
7589 assert(image != (Image **) NULL);
7590 msl_image=AcquireImage(image_info);
7591 status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
7592 if (status == MagickFalse)
7594 ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
7595 msl_image->filename);
7596 msl_image=DestroyImageList(msl_image);
7597 return(MagickFalse);
7599 msl_image->columns=1;
7604 (void) ResetMagickMemory(&msl_info,0,sizeof(msl_info));
7605 msl_info.exception=exception;
7606 msl_info.image_info=(ImageInfo **) AcquireMagickMemory(
7607 sizeof(*msl_info.image_info));
7608 msl_info.draw_info=(DrawInfo **) AcquireMagickMemory(
7609 sizeof(*msl_info.draw_info));
7610 /* top of the stack is the MSL file itself */
7611 msl_info.image=(Image **) AcquireMagickMemory(sizeof(*msl_info.image));
7612 msl_info.attributes=(Image **) AcquireMagickMemory(
7613 sizeof(*msl_info.attributes));
7614 msl_info.group_info=(MSLGroupInfo *) AcquireMagickMemory(
7615 sizeof(*msl_info.group_info));
7616 if ((msl_info.image_info == (ImageInfo **) NULL) ||
7617 (msl_info.image == (Image **) NULL) ||
7618 (msl_info.attributes == (Image **) NULL) ||
7619 (msl_info.group_info == (MSLGroupInfo *) NULL))
7620 ThrowFatalException(ResourceLimitFatalError,
7621 "UnableToInterpretMSLImage");
7622 *msl_info.image_info=CloneImageInfo(image_info);
7623 *msl_info.draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
7624 *msl_info.attributes=AcquireImage(image_info);
7625 msl_info.group_info[0].numImages=0;
7626 /* the first slot is used to point to the MSL file image */
7627 *msl_info.image=msl_image;
7628 if (*image != (Image *) NULL)
7629 MSLPushImage(&msl_info,*image);
7630 (void) xmlSubstituteEntitiesDefault(1);
7631 (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
7632 sax_modules.internalSubset=MSLInternalSubset;
7633 sax_modules.isStandalone=MSLIsStandalone;
7634 sax_modules.hasInternalSubset=MSLHasInternalSubset;
7635 sax_modules.hasExternalSubset=MSLHasExternalSubset;
7636 sax_modules.resolveEntity=MSLResolveEntity;
7637 sax_modules.getEntity=MSLGetEntity;
7638 sax_modules.entityDecl=MSLEntityDeclaration;
7639 sax_modules.notationDecl=MSLNotationDeclaration;
7640 sax_modules.attributeDecl=MSLAttributeDeclaration;
7641 sax_modules.elementDecl=MSLElementDeclaration;
7642 sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
7643 sax_modules.setDocumentLocator=MSLSetDocumentLocator;
7644 sax_modules.startDocument=MSLStartDocument;
7645 sax_modules.endDocument=MSLEndDocument;
7646 sax_modules.startElement=MSLStartElement;
7647 sax_modules.endElement=MSLEndElement;
7648 sax_modules.reference=MSLReference;
7649 sax_modules.characters=MSLCharacters;
7650 sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
7651 sax_modules.processingInstruction=MSLProcessingInstructions;
7652 sax_modules.comment=MSLComment;
7653 sax_modules.warning=MSLWarning;
7654 sax_modules.error=MSLError;
7655 sax_modules.fatalError=MSLError;
7656 sax_modules.getParameterEntity=MSLGetParameterEntity;
7657 sax_modules.cdataBlock=MSLCDataBlock;
7658 sax_modules.externalSubset=MSLExternalSubset;
7659 sax_handler=(&sax_modules);
7660 msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
7661 msl_image->filename);
7662 while (ReadBlobString(msl_image,message) != (char *) NULL)
7664 n=(ssize_t) strlen(message);
7667 status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
7670 (void) xmlParseChunk(msl_info.parser," ",1,MagickFalse);
7671 if (msl_info.exception->severity >= ErrorException)
7674 if (msl_info.exception->severity == UndefinedException)
7675 (void) xmlParseChunk(msl_info.parser," ",1,MagickTrue);
7676 xmlFreeParserCtxt(msl_info.parser);
7677 (void) LogMagickEvent(CoderEvent,GetMagickModule(),"end SAX");
7679 msl_info.group_info=(MSLGroupInfo *) RelinquishMagickMemory(
7680 msl_info.group_info);
7681 if (*image == (Image *) NULL)
7682 *image=(*msl_info.image);
7683 if ((*msl_info.image)->exception.severity != UndefinedException)
7684 return(MagickFalse);
7688 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
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(exception != (ExceptionInfo *) NULL);
7702 assert(exception->signature == MagickSignature);
7703 image=(Image *) NULL;
7704 (void) ProcessMSLScript(image_info,&image,exception);
7705 return(GetFirstImageInList(image));
7710 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7714 % R e g i s t e r M S L I m a g e %
7718 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7720 % RegisterMSLImage() adds attributes for the MSL image format to
7721 % the list of supported formats. The attributes include the image format
7722 % tag, a method to read and/or write the format, whether the format
7723 % supports the saving of more than one frame to the same file or blob,
7724 % whether the format supports native in-memory I/O, and a brief
7725 % description of the format.
7727 % The format of the RegisterMSLImage method is:
7729 % size_t RegisterMSLImage(void)
7732 ModuleExport size_t RegisterMSLImage(void)
7737 entry=SetMagickInfo("MSL");
7738 #if defined(MAGICKCORE_XML_DELEGATE)
7739 entry->decoder=(DecodeImageHandler *) ReadMSLImage;
7740 entry->encoder=(EncodeImageHandler *) WriteMSLImage;
7742 entry->description=ConstantString("Magick Scripting Language");
7743 entry->module=ConstantString("MSL");
7744 (void) RegisterMagickInfo(entry);
7745 return(MagickImageCoderSignature);
7748 #if defined(MAGICKCORE_XML_DELEGATE)
7750 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7754 % S e t M S L A t t r i b u t e s %
7758 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7760 % SetMSLAttributes() ...
7762 % The format of the SetMSLAttributes method is:
7764 % MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
7765 % const char *keyword,const char *value)
7767 % A description of each parameter follows:
7769 % o msl_info: the MSL info.
7771 % o keyword: the keyword.
7773 % o value: the value.
7776 static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
7803 assert(msl_info != (MSLInfo *) NULL);
7804 if (keyword == (const char *) NULL)
7806 if (value == (const char *) NULL)
7808 exception=msl_info->exception;
7810 attributes=msl_info->attributes[n];
7811 image_info=msl_info->image_info[n];
7812 draw_info=msl_info->draw_info[n];
7813 image=msl_info->image[n];
7819 if (LocaleCompare(keyword,"adjoin") == 0)
7824 adjoin=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7826 ThrowMSLException(OptionError,"UnrecognizedType",value);
7827 image_info->adjoin=(MagickBooleanType) adjoin;
7830 if (LocaleCompare(keyword,"alpha") == 0)
7835 alpha=ParseCommandOption(MagickAlphaOptions,MagickFalse,value);
7837 ThrowMSLException(OptionError,"UnrecognizedType",value);
7838 if (image != (Image *) NULL)
7839 (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
7842 if (LocaleCompare(keyword,"antialias") == 0)
7847 antialias=ParseCommandOption(MagickBooleanOptions,MagickFalse,value);
7849 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7850 image_info->antialias=(MagickBooleanType) antialias;
7853 if (LocaleCompare(keyword,"area-limit") == 0)
7858 limit=MagickResourceInfinity;
7859 if (LocaleCompare(value,"unlimited") != 0)
7860 limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
7861 (void) SetMagickResourceLimit(AreaResource,limit);
7864 if (LocaleCompare(keyword,"attenuate") == 0)
7866 (void) SetImageOption(image_info,keyword,value);
7869 if (LocaleCompare(keyword,"authenticate") == 0)
7871 (void) CloneString(&image_info->density,value);
7874 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7880 if (LocaleCompare(keyword,"background") == 0)
7882 (void) QueryColorDatabase(value,&image_info->background_color,
7886 if (LocaleCompare(keyword,"bias") == 0)
7888 if (image == (Image *) NULL)
7890 image->bias=SiPrefixToDouble(value,QuantumRange);
7893 if (LocaleCompare(keyword,"blue-primary") == 0)
7895 if (image == (Image *) NULL)
7897 flags=ParseGeometry(value,&geometry_info);
7898 image->chromaticity.blue_primary.x=geometry_info.rho;
7899 image->chromaticity.blue_primary.y=geometry_info.sigma;
7900 if ((flags & SigmaValue) == 0)
7901 image->chromaticity.blue_primary.y=
7902 image->chromaticity.blue_primary.x;
7905 if (LocaleCompare(keyword,"bordercolor") == 0)
7907 (void) QueryColorDatabase(value,&image_info->border_color,
7911 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7917 if (LocaleCompare(keyword,"density") == 0)
7919 (void) CloneString(&image_info->density,value);
7920 (void) CloneString(&draw_info->density,value);
7923 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7929 if (LocaleCompare(keyword,"fill") == 0)
7931 (void) QueryColorDatabase(value,&draw_info->fill,exception);
7932 (void) SetImageOption(image_info,keyword,value);
7935 if (LocaleCompare(keyword,"filename") == 0)
7937 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
7940 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7946 if (LocaleCompare(keyword,"gravity") == 0)
7951 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
7953 ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
7954 (void) SetImageOption(image_info,keyword,value);
7957 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7963 if (LocaleCompare(keyword,"id") == 0)
7965 (void) SetImageProperty(attributes,keyword,value);
7968 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7974 if (LocaleCompare(keyword,"magick") == 0)
7976 (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
7979 if (LocaleCompare(keyword,"mattecolor") == 0)
7981 (void) QueryColorDatabase(value,&image_info->matte_color,
7985 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
7991 if (LocaleCompare(keyword,"pointsize") == 0)
7993 image_info->pointsize=StringToDouble(value);
7994 draw_info->pointsize=StringToDouble(value);
7997 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8003 if (LocaleCompare(keyword,"quality") == 0)
8005 image_info->quality=StringToLong(value);
8006 if (image == (Image *) NULL)
8008 image->quality=StringToLong(value);
8016 if (LocaleCompare(keyword,"size") == 0)
8018 (void) CloneString(&image_info->size,value);
8021 if (LocaleCompare(keyword,"stroke") == 0)
8023 (void) QueryColorDatabase(value,&draw_info->stroke,exception);
8024 (void) SetImageOption(image_info,keyword,value);
8027 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8032 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
8041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8045 % U n r e g i s t e r M S L I m a g e %
8049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8051 % UnregisterMSLImage() removes format registrations made by the
8052 % MSL module from the list of supported formats.
8054 % The format of the UnregisterMSLImage method is:
8056 % UnregisterMSLImage(void)
8059 ModuleExport void UnregisterMSLImage(void)
8061 (void) UnregisterMagickInfo("MSL");
8064 #if defined(MAGICKCORE_XML_DELEGATE)
8066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8070 % W r i t e M S L I m a g e %
8074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8076 % WriteMSLImage() writes an image to a file in MVG image format.
8078 % The format of the WriteMSLImage method is:
8080 % MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8082 % A description of each parameter follows.
8084 % o image_info: the image info.
8086 % o image: The image.
8089 static MagickBooleanType WriteMSLImage(const ImageInfo *image_info,Image *image)
8091 assert(image_info != (const ImageInfo *) NULL);
8092 assert(image_info->signature == MagickSignature);
8093 assert(image != (Image *) NULL);
8094 assert(image->signature == MagickSignature);
8095 if (image->debug != MagickFalse)
8096 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
8097 (void) ReferenceImage(image);
8098 (void) ProcessMSLScript(image_info,&image,&image->exception);