]> granicus.if.org Git - imagemagick/blobdiff - coders/msl.c
(no commit message)
[imagemagick] / coders / msl.c
index edf316a8ea8209a40eb6dfafd5394ff36b85adb4..f0204a4f580f7ff7901eb5f281536658fe796ce3 100644 (file)
@@ -19,7 +19,7 @@
 %                               December 2001                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -49,6 +49,7 @@
 #include "magick/cache.h"
 #include "magick/cache-view.h"
 #include "magick/color.h"
+#include "magick/colormap.h"
 #include "magick/color-private.h"
 #include "magick/composite.h"
 #include "magick/constitute.h"
 #include "magick/log.h"
 #include "magick/magick.h"
 #include "magick/memory_.h"
+#include "magick/module.h"
 #include "magick/option.h"
 #include "magick/paint.h"
+#include "magick/profile.h"
 #include "magick/property.h"
 #include "magick/quantize.h"
 #include "magick/quantum-private.h"
+#include "magick/registry.h"
 #include "magick/resize.h"
+#include "magick/resource_.h"
 #include "magick/segment.h"
 #include "magick/shear.h"
 #include "magick/signature.h"
 #include "magick/static.h"
 #include "magick/string_.h"
-#include "magick/module.h"
+#include "magick/string-private.h"
 #include "magick/transform.h"
 #include "magick/threshold.h"
 #include "magick/utility.h"
 #if defined(MAGICKCORE_XML_DELEGATE)
-#  if defined(__WINDOWS__)
+#  if defined(MAGICKCORE_WINDOWS_SUPPORT)
 #    if defined(__MINGW32__)
 #      define _MSC_VER
 #    else
 */
 typedef struct _MSLGroupInfo
 {
-  unsigned long
+  size_t
     numImages;  /* how many images are in this group */
 } MSLGroupInfo;
 
@@ -117,7 +122,7 @@ typedef struct _MSLInfo
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     n,
     number_groups;
 
@@ -152,9 +157,13 @@ typedef struct _MSLInfo
 #if defined(MAGICKCORE_XML_DELEGATE)
 static MagickBooleanType
   WriteMSLImage(const ImageInfo *,Image *);
+
+static MagickBooleanType
+  SetMSLAttributes(MSLInfo *,const char *,const char *);
 #endif
 \f
 #if defined(MAGICKCORE_XML_DELEGATE)
+\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -180,13 +189,60 @@ static MagickBooleanType
 %
 %    o exception: return any errors or warnings in this structure.
 %
-%
 */
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
+static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
+  ExceptionInfo *exception)
+{
+  char
+    key[MaxTextExtent];
+
+  ExceptionInfo
+    *sans_exception;
+
+  Image
+    *image;
+
+  ImageInfo
+    *read_info;
+
+  (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
+  sans_exception=AcquireExceptionInfo();
+  image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
+  sans_exception=DestroyExceptionInfo(sans_exception);
+  if (image != (Image *) NULL)
+    return(image);
+  read_info=CloneImageInfo(image_info);
+  (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
+  image=ReadImage(read_info,exception);
+  read_info=DestroyImageInfo(read_info);
+  if (image != (Image *) NULL)
+    (void) SetImageRegistry(ImageRegistryType,key,image,exception);
+  return(image);
+}
+
+static int IsPathDirectory(const char *path)
+{
+  MagickBooleanType
+    status;
+
+  struct stat
+    attributes;
+
+  if ((path == (const char *) NULL) || (*path == '\0'))
+    return(MagickFalse);
+  status=GetPathAttributes(path,&attributes);
+  if (status == MagickFalse)
+    return(-1);
+  if (S_ISDIR(attributes.st_mode) == 0)
+    return(0);
+  return(1);
+}
+
 static int MSLIsStandalone(void *context)
 {
   MSLInfo
@@ -239,8 +295,8 @@ static void MSLInternalSubset(void *context,const xmlChar *name,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.internalSubset(%s %s %s)",name,
-    (external_id != (const xmlChar *) NULL ? (char *) external_id : " "),
-    (system_id != (const xmlChar *) NULL ? (char *) system_id : " "));
+    (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
+    (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
   msl_info=(MSLInfo *) context;
   (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id);
 }
@@ -262,8 +318,8 @@ static xmlParserInputPtr MSLResolveEntity(void *context,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.resolveEntity(%s, %s)",
-    (public_id != (const xmlChar *) NULL ? (char *) public_id : "none"),
-    (system_id != (const xmlChar *) NULL ? (char *) system_id : "none"));
+    (public_id != (const xmlChar *) NULL ? (const char *) public_id : "none"),
+    (system_id != (const xmlChar *) NULL ? (const char *) system_id : "none"));
   msl_info=(MSLInfo *) context;
   stream=xmlLoadExternalEntity((const char *) system_id,(const char *)
     public_id,msl_info->parser);
@@ -279,7 +335,7 @@ static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name)
     Get an entity by name.
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-    "  SAX.MSLGetEntity(%s)",(char *) name);
+    "  SAX.MSLGetEntity(%s)",(const char *) name);
   msl_info=(MSLInfo *) context;
   return(xmlGetDocEntity(msl_info->document,name));
 }
@@ -293,7 +349,7 @@ static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name)
     Get a parameter entity by name.
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-    "  SAX.getParameterEntity(%s)",(char *) name);
+    "  SAX.getParameterEntity(%s)",(const char *) name);
   msl_info=(MSLInfo *) context;
   return(xmlGetParameterEntity(msl_info->document,name));
 }
@@ -309,8 +365,9 @@ static void MSLEntityDeclaration(void *context,const xmlChar *name,int type,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.entityDecl(%s, %d, %s, %s, %s)",name,type,
-    public_id != (const xmlChar *) NULL ? (char *) public_id : "none",
-    system_id != (const xmlChar *) NULL ? (char *) system_id : "none",content);
+    public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
+    system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
+    content);
   msl_info=(MSLInfo *) context;
   if (msl_info->parser->inSubset == 1)
     (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id,
@@ -400,8 +457,8 @@ static void MSLNotationDeclaration(void *context,const xmlChar *name,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.notationDecl(%s, %s, %s)",name,
-    public_id != (const xmlChar *) NULL ? (char *) public_id : "none",
-    system_id != (const xmlChar *) NULL ? (char *) system_id : "none");
+    public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
+    system_id != (const xmlChar *) NULL ? (const char *) system_id : "none");
   msl_info=(MSLInfo *) context;
   parser=msl_info->parser;
   if (parser->inSubset == 1)
@@ -424,8 +481,9 @@ static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.unparsedEntityDecl(%s, %s, %s, %s)",name,
-    public_id != (const xmlChar *) NULL ? (char *) public_id : "none",
-    system_id != (const xmlChar *) NULL ? (char *) system_id : "none",notation);
+    public_id != (const xmlChar *) NULL ? (const char *) public_id : "none",
+    system_id != (const xmlChar *) NULL ? (const char *) system_id : "none",
+    notation);
   msl_info=(MSLInfo *) context;
   (void) xmlAddDocEntity(msl_info->document,name,
     XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation);
@@ -487,7 +545,7 @@ static void MSLEndDocument(void *context)
 
 static void MSLPushImage(MSLInfo *msl_info,Image *image)
 {
-  long
+  ssize_t
     n;
 
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
@@ -571,7 +629,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
   int
     flags;
 
-  long
+  ssize_t
     option,
     j,
     n,
@@ -584,10 +642,10 @@ static void MSLStartElement(void *context,const xmlChar *tag,
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -608,7 +666,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'A':
     case 'a':
     {
-      if (LocaleCompare((char *) tag,"add-noise") == 0)
+      if (LocaleCompare((const char *) tag,"add-noise") == 0)
         {
           Image
             *noise_image;
@@ -621,7 +679,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           noise=UniformNoise;
@@ -630,7 +689,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -683,7 +742,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=noise_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"annotate") == 0)
+      if (LocaleCompare((const char *) tag,"annotate") == 0)
         {
           char
             text[MaxTextExtent];
@@ -693,7 +752,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           draw_info=CloneDrawInfo(msl_info->image_info[n],
@@ -706,7 +766,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -839,7 +899,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"pointsize") == 0)
                     {
-                      draw_info->pointsize=atof(value);
+                      draw_info->pointsize=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -851,7 +911,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"rotate") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
                       affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
                       affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
@@ -876,14 +936,14 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"skewX") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.ry=tan(DegreesToRadians(fmod((double) angle,
                         360.0)));
                       break;
                     }
                   if (LocaleCompare(keyword,"skewY") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.rx=tan(DegreesToRadians(fmod((double) angle,
                         360.0)));
                       break;
@@ -906,7 +966,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=atol(value);
+                      draw_info->stroke_width=StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -962,7 +1022,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"weight") == 0)
                     {
-                      draw_info->weight=atol(value);
+                      draw_info->weight=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -974,7 +1034,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -986,7 +1046,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1001,32 +1061,34 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               }
             }
-          (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
-            geometry.width,geometry.height,geometry.x,geometry.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
+            geometry.height,(double) geometry.x,(double) geometry.y);
           CloneString(&draw_info->geometry,text);
-          draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
-          draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
-          draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
-          draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
-          draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
-            current.tx;
-          draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
-            current.ty;
+          draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
+          draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
+          draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
+          draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
+          draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
+            affine.tx;
+          draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
+            affine.ty;
           (void) AnnotateImage(msl_info->image[n],draw_info);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
-      if (LocaleCompare((char *) tag,"append") == 0)
+      if (LocaleCompare((const char *) tag,"append") == 0)
         {
           Image
             *append_image;
 
           MagickBooleanType
             stack;
-   
+
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           stack=MagickFalse;
@@ -1035,7 +1097,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1078,7 +1140,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'B':
     case 'b':
     {
-      if (LocaleCompare((char *) tag,"blur") == 0)
+      if (LocaleCompare((const char *) tag,"blur") == 0)
         {
           Image
             *blur_image;
@@ -1088,7 +1150,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -1096,7 +1159,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1135,7 +1198,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1147,7 +1210,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"sigma") == 0)
                     {
-                      geometry_info.sigma=atol(value);
+                      geometry_info.sigma=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1171,7 +1234,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=blur_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"border") == 0)
+      if (LocaleCompare((const char *) tag,"border") == 0)
         {
           Image
             *border_image;
@@ -1181,7 +1244,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -1190,7 +1254,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1244,7 +1308,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=atol(value);
+                      geometry.height=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1256,7 +1320,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1284,7 +1348,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'C':
     case 'c':
     {
-      if (LocaleCompare((char *) tag,"colorize") == 0)
+      if (LocaleCompare((const char *) tag,"colorize") == 0)
         {
           char
             opacity[MaxTextExtent];
@@ -1300,7 +1364,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           target=msl_info->image[n]->background_color;
@@ -1310,7 +1375,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1355,14 +1420,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=colorize_image;
           break;
         }
-      if (LocaleCompare((char *) tag, "charcoal") == 0)
+      if (LocaleCompare((const char *) tag, "charcoal") == 0)
       {
         double  radius = 0.0,
             sigma = 1.0;
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         /*
@@ -1374,7 +1440,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           keyword=(const char *) attributes[i++];
           CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-            msl_info->attributes[n],(char *) attributes[i]));
+            msl_info->attributes[n],(const char *) attributes[i]));
           switch (*keyword)
           {
             case 'R':
@@ -1382,7 +1448,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword, "radius") == 0)
               {
-                radius = atof( value );
+                radius = StringToDouble( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -1393,7 +1459,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword,"sigma") == 0)
               {
-                sigma = atol( value );
+                sigma = StringToLong( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -1424,7 +1490,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         break;
         }
       }
-      if (LocaleCompare((char *) tag,"chop") == 0)
+      if (LocaleCompare((const char *) tag,"chop") == 0)
         {
           Image
             *chop_image;
@@ -1434,7 +1500,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -1443,7 +1510,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1467,7 +1534,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=atol(value);
+                      geometry.height=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1479,7 +1546,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1491,7 +1558,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1503,7 +1570,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1526,7 +1593,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=chop_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"color-floodfill") == 0)
+      if (LocaleCompare((const char *) tag,"color-floodfill") == 0)
         {
           PaintMethod
             paint_method;
@@ -1539,7 +1606,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           draw_info=CloneDrawInfo(msl_info->image_info[n],
@@ -1551,7 +1619,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1579,7 +1647,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"fuzz") == 0)
                     {
-                      msl_info->image[n]->fuzz=atof(value);
+                      msl_info->image[n]->fuzz=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1608,7 +1676,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       (void) GetOneVirtualMagickPixel(msl_info->image[n],
                         geometry.x,geometry.y,&target,&exception);
                       break;
@@ -1622,7 +1690,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       (void) GetOneVirtualMagickPixel(msl_info->image[n],
                         geometry.x,geometry.y,&target,&exception);
                       break;
@@ -1645,9 +1713,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
-      if (LocaleCompare((char *) tag,"comment") == 0)
+      if (LocaleCompare((const char *) tag,"comment") == 0)
         break;
-      if (LocaleCompare((char *) tag,"composite") == 0)
+      if (LocaleCompare((const char *) tag,"composite") == 0)
         {
           char
             composite_geometry[MaxTextExtent];
@@ -1667,7 +1735,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           composite_image=NewImageList();
@@ -1677,7 +1746,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1704,7 +1773,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     {
                       const char
                         *attribute;
-    
+
                       attribute=GetImageProperty(msl_info->attributes[j],"id");
                       if ((attribute != (const char *) NULL)  &&
                           (LocaleCompare(attribute,value) == 0))
@@ -1729,7 +1798,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -1834,23 +1903,24 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"opacity") == 0)
                     {
-                      long
+                      ssize_t
                         opacity,
                         y;
-                    
-                      register long
+
+                      register ssize_t
                         x;
-                    
+
                       register PixelPacket
                         *q;
-                    
+
                       CacheView
                         *composite_view;
 
-                      opacity=QuantumRange-atol(value);
+                      opacity=QuantumRange-StringToLong(value);
                       if (compose != DissolveCompositeOp)
                         {
-                          (void) SetImageOpacity(composite_image,(Quantum) opacity);
+                          (void) SetImageOpacity(composite_image,(Quantum)
+                            opacity);
                           break;
                         }
                       (void) SetImageArtifact(msl_info->image[n],
@@ -1858,14 +1928,14 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                       if (composite_image->matte != MagickTrue)
                         (void) SetImageOpacity(composite_image,OpaqueOpacity);
                       composite_view=AcquireCacheView(composite_image);
-                      for (y=0; y < (long) composite_image->rows ; y++)
-                      { 
-                        q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
+                      for (y=0; y < (ssize_t) composite_image->rows ; y++)
+                      {
+                        q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
                           composite_image->columns,1,&exception);
-                        for (x=0; x < (long) composite_image->columns; x++)
-                        { 
+                        for (x=0; x < (ssize_t) composite_image->columns; x++)
+                        {
                           if (q->opacity == OpaqueOpacity)
-                            q->opacity=RoundToQuantum(opacity);
+                            q->opacity=ClampToQuantum(opacity);
                           q++;
                         }
                         if (SyncCacheViewAuthenticPixels(composite_view,&exception) == MagickFalse)
@@ -1883,7 +1953,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"rotate") == 0)
                     {
-                      rotate_image=RotateImage(composite_image,atof(value),
+                      rotate_image=RotateImage(composite_image,StringToDouble(value),
                         &exception);
                       break;
                     }
@@ -1914,8 +1984,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                        image=msl_info->image[n];
                        height=composite_image->rows;
                        width=composite_image->columns;
-                       for (y=0; y < (long) image->rows; y+=height)
-                         for (x=0; x < (long) image->columns; x+=width)
+                       for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height)
+                         for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width)
                          {
                            if (rotate_image != (Image *) NULL)
                              (void) CompositeImage(image,compose,rotate_image,
@@ -1937,7 +2007,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
                         geometry.y,&target,&exception);
                       break;
@@ -1951,7 +2021,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       (void) GetOneVirtualPixel(msl_info->image[n],geometry.x,
                         geometry.y,&target,&exception);
                       break;
@@ -1970,8 +2040,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             }
           image=msl_info->image[n];
           (void) FormatMagickString(composite_geometry,MaxTextExtent,
-            "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
-            geometry.x,geometry.y);
+            "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
+            (double) composite_image->rows,(double) geometry.x,(double)
+            geometry.y);
           flags=ParseGravityGeometry(image,composite_geometry,&geometry,
             &exception);
           if (rotate_image == (Image *) NULL)
@@ -1982,9 +2053,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               /*
                 Rotate image.
               */
-              geometry.x-=(long) (rotate_image->columns-
+              geometry.x-=(ssize_t) (rotate_image->columns-
                 composite_image->columns)/2;
-              geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
+              geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
               CompositeImageChannel(image,channel,compose,rotate_image,
                 geometry.x,geometry.y);
               rotate_image=DestroyImage(rotate_image);
@@ -1992,7 +2063,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           composite_image=DestroyImage(composite_image);
           break;
         }
-      if (LocaleCompare((char *) tag,"contrast") == 0)
+      if (LocaleCompare((const char *) tag,"contrast") == 0)
         {
           MagickBooleanType
             sharpen;
@@ -2002,7 +2073,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           sharpen=MagickFalse;
@@ -2011,7 +2083,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2043,7 +2115,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) ContrastImage(msl_info->image[n],sharpen);
           break;
         }
-      if (LocaleCompare((char *) tag,"crop") == 0)
+      if (LocaleCompare((const char *) tag,"crop") == 0)
         {
           Image
             *crop_image;
@@ -2053,7 +2125,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -2062,7 +2135,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2086,7 +2159,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=atol(value);
+                      geometry.height=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2098,7 +2171,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2110,7 +2183,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2122,7 +2195,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2145,9 +2218,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=crop_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"cycle-colormap") == 0)
+      if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
         {
-          long
+          ssize_t
             display;
 
           /*
@@ -2155,7 +2228,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           display=0;
@@ -2164,7 +2238,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2173,7 +2247,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"display") == 0)
                     {
-                      display=atol(value);
+                      display=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2196,7 +2270,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'D':
     case 'd':
     {
-      if (LocaleCompare((char *) tag,"despeckle") == 0)
+      if (LocaleCompare((const char *) tag,"despeckle") == 0)
         {
           Image
             *despeckle_image;
@@ -2206,7 +2280,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2214,7 +2289,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -2226,11 +2301,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=despeckle_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"display") == 0)
+      if (LocaleCompare((const char *) tag,"display") == 0)
         {
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2238,7 +2314,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2253,7 +2329,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]);
           break;
         }
-      if (LocaleCompare((char *) tag,"draw") == 0)
+      if (LocaleCompare((const char *) tag,"draw") == 0)
         {
           char
             text[MaxTextExtent];
@@ -2263,7 +2339,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           draw_info=CloneDrawInfo(msl_info->image_info[n],
@@ -2276,7 +2353,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2408,13 +2485,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 case 'p':
                 {
                   if (LocaleCompare(keyword,"primitive") == 0)
-                    { 
+                    {
                       CloneString(&draw_info->primitive,value);
                       break;
                     }
                   if (LocaleCompare(keyword,"pointsize") == 0)
                     {
-                      draw_info->pointsize=atof(value);
+                      draw_info->pointsize=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2426,7 +2503,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"rotate") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
                       affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
                       affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
@@ -2451,13 +2528,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"skewX") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
                       break;
                     }
                   if (LocaleCompare(keyword,"skewY") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
                       break;
                     }
@@ -2479,7 +2556,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=atol(value);
+                      draw_info->stroke_width=StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -2535,7 +2612,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"weight") == 0)
                     {
-                      draw_info->weight=atol(value);
+                      draw_info->weight=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2547,7 +2624,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2559,7 +2636,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2574,17 +2651,18 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               }
             }
-          (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
-            geometry.width,geometry.height,geometry.x,geometry.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
+            geometry.height,(double) geometry.x,(double) geometry.y);
           CloneString(&draw_info->geometry,text);
-          draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
-          draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
-          draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
-          draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
-          draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
-            current.tx;
-          draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
-            current.ty;
+          draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
+          draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
+          draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
+          draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
+          draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
+            affine.tx;
+          draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
+            affine.ty;
           (void) DrawImage(msl_info->image[n],draw_info);
           draw_info=DestroyDrawInfo(draw_info);
           break;
@@ -2594,7 +2672,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'E':
     case 'e':
     {
-      if (LocaleCompare((char *) tag,"edge") == 0)
+      if (LocaleCompare((const char *) tag,"edge") == 0)
         {
           Image
             *edge_image;
@@ -2604,7 +2682,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2612,7 +2691,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2635,7 +2714,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2658,7 +2737,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=edge_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"emboss") == 0)
+      if (LocaleCompare((const char *) tag,"emboss") == 0)
         {
           Image
             *emboss_image;
@@ -2668,7 +2747,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2676,7 +2756,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2699,7 +2779,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2711,7 +2791,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"sigma") == 0)
                     {
-                      geometry_info.sigma=atol(value);
+                      geometry_info.sigma=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2734,7 +2814,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=emboss_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"enhance") == 0)
+      if (LocaleCompare((const char *) tag,"enhance") == 0)
         {
           Image
             *enhance_image;
@@ -2744,7 +2824,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2752,7 +2833,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -2764,14 +2845,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=enhance_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"equalize") == 0)
+      if (LocaleCompare((const char *) tag,"equalize") == 0)
         {
           /*
             Equalize image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2779,7 +2861,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2799,11 +2881,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'F':
     case 'f':
     {
-      if (LocaleCompare((char *) tag, "flatten") == 0)
+      if (LocaleCompare((const char *) tag, "flatten") == 0)
       {
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
 
@@ -2823,7 +2906,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           break;
         }
       }
-      if (LocaleCompare((char *) tag,"flip") == 0)
+      if (LocaleCompare((const char *) tag,"flip") == 0)
         {
           Image
             *flip_image;
@@ -2833,7 +2916,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2841,7 +2925,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -2853,7 +2937,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=flip_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"flop") == 0)
+      if (LocaleCompare((const char *) tag,"flop") == 0)
         {
           Image
             *flop_image;
@@ -2863,7 +2947,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -2871,7 +2956,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -2883,7 +2968,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=flop_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"frame") == 0)
+      if (LocaleCompare((const char *) tag,"frame") == 0)
         {
           FrameInfo
             frame_info;
@@ -2896,7 +2981,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -2905,7 +2991,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -2963,7 +3049,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      frame_info.height=atol(value);
+                      frame_info.height=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2975,7 +3061,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"inner") == 0)
                     {
-                      frame_info.inner_bevel=atol(value);
+                      frame_info.inner_bevel=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2987,7 +3073,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"outer") == 0)
                     {
-                      frame_info.outer_bevel=atol(value);
+                      frame_info.outer_bevel=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -2999,7 +3085,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      frame_info.width=atol(value);
+                      frame_info.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3014,8 +3100,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               }
             }
-          frame_info.x=(long) frame_info.width;
-          frame_info.y=(long) frame_info.height;
+          frame_info.x=(ssize_t) frame_info.width;
+          frame_info.y=(ssize_t) frame_info.height;
           frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
           frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
           frame_image=FrameImage(msl_info->image[n],&frame_info,
@@ -3031,7 +3117,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'G':
     case 'g':
     {
-      if (LocaleCompare((char *) tag,"gamma") == 0)
+      if (LocaleCompare((const char *) tag,"gamma") == 0)
         {
           char
             gamma[MaxTextExtent];
@@ -3044,7 +3130,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           channel=UndefinedChannel;
@@ -3057,7 +3144,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3066,7 +3153,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"blue") == 0)
                     {
-                      pixel.blue=atof(value);
+                      pixel.blue=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3099,7 +3186,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"green") == 0)
                     {
-                      pixel.green=atof(value);
+                      pixel.green=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3111,7 +3198,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"red") == 0)
                     {
-                      pixel.red=atof(value);
+                      pixel.red=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3129,7 +3216,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           if (*gamma == '\0')
             (void) FormatMagickString(gamma,MaxTextExtent,"%g,%g,%g",
               (double) pixel.red,(double) pixel.green,(double) pixel.blue);
-          switch (channel)          
+          switch (channel)
           {
             default:
             {
@@ -3156,11 +3243,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           }
           break;
         }
-      else if (LocaleCompare((char *) tag,"get") == 0)
+      else if (LocaleCompare((const char *) tag,"get") == 0)
         {
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes == (const xmlChar **) NULL)
@@ -3168,7 +3256,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
           {
             keyword=(const char *) attributes[i++];
-            CloneString(&value,(char *) attributes[i]);
+            CloneString(&value,(const char *) attributes[i]);
             (void) CopyMagickString(key,value,MaxTextExtent);
             switch (*keyword)
             {
@@ -3177,8 +3265,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               {
                 if (LocaleCompare(keyword,"height") == 0)
                   {
-                    (void) FormatMagickString(value,MaxTextExtent,"%ld",
-                      msl_info->image[n]->rows);
+                    (void) FormatMagickString(value,MaxTextExtent,"%.20g",
+                      (double) msl_info->image[n]->rows);
                     (void) SetImageProperty(msl_info->attributes[n],key,value);
                     break;
                   }
@@ -3189,8 +3277,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               {
                 if (LocaleCompare(keyword,"width") == 0)
                   {
-                    (void) FormatMagickString(value,MaxTextExtent,"%ld",
-                      msl_info->image[n]->columns);
+                    (void) FormatMagickString(value,MaxTextExtent,"%.20g",
+                      (double) msl_info->image[n]->columns);
                     (void) SetImageProperty(msl_info->attributes[n],key,value);
                     break;
                   }
@@ -3205,7 +3293,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           }
           break;
         }
-    else if (LocaleCompare((char *) tag, "group") == 0)
+    else if (LocaleCompare((const char *) tag, "group") == 0)
     {
       msl_info->number_groups++;
       msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory(
@@ -3218,105 +3306,65 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'I':
     case 'i':
     {
-      if (LocaleCompare((char *) tag,"image") == 0)
+      if (LocaleCompare((const char *) tag,"image") == 0)
         {
-          long
-            n;
-
           MSLPushImage(msl_info,(Image *) NULL);
-          n=msl_info->n;
           if (attributes == (const xmlChar **) NULL)
             break;
           for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
           {
             keyword=(const char *) attributes[i++];
             CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-              msl_info->attributes[n],(char *) attributes[i]));
+              msl_info->attributes[n],(const char *) attributes[i]));
             switch (*keyword)
             {
-      case 'B':
-      case 'b':
-        {
-          if (LocaleCompare(keyword,"background") == 0)
-          {
-            (void) QueryColorDatabase(value,
-              &msl_info->image_info[n]->background_color,&exception);
-            break;
-          }
-          ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-          break;
-        }
-
-      case 'C':
-      case 'c':
-        {
-          if (LocaleCompare(keyword,"color") == 0)
-          {
-            Image
-              *next_image;
-
-            (void) CopyMagickString(msl_info->image_info[n]->filename,"xc:",
-              MaxTextExtent);
-            (void) ConcatenateMagickString(msl_info->image_info[n]->filename,
-              value,MaxTextExtent);
-            next_image=ReadImage(msl_info->image_info[n],&exception);
-            CatchException(&exception);
-            if (next_image == (Image *) NULL)
-              continue;
-            if (msl_info->image[n] == (Image *) NULL)
-              msl_info->image[n]=next_image;
-            else
+              case 'C':
+              case 'c':
               {
-              register Image
-                *p;
-
-              /*
-                Link image into image list.
-              */
-              p=msl_info->image[n];
-              for ( ; p->next != (Image *) NULL; p=GetNextImageInList(p)) ;
-              next_image->previous=p;
-              p->next=next_image;
-              }
-            break;
-          }
-          ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-          break;
-        }
+                if (LocaleCompare(keyword,"color") == 0)
+                  {
+                    Image
+                      *next_image;
 
-      case 'I':
-      case 'i':
-        {
-          if (LocaleCompare(keyword,"id") == 0)
-          {
-            (void) SetImageProperty(msl_info->attributes[n],keyword,NULL);  /* make sure to clear it! */
-            (void) SetImageProperty(msl_info->attributes[n],keyword,value);
-            break;
-          }
-          ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-          break;
-        }
-              case 'S':
-              case 's':
-              {
-                if (LocaleCompare(keyword,"size") == 0)
-                {
-          CloneString(&msl_info->image_info[n]->size,value);
-          break;
-        }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                    (void) CopyMagickString(msl_info->image_info[n]->filename,
+                      "xc:",MaxTextExtent);
+                    (void) ConcatenateMagickString(msl_info->image_info[n]->
+                      filename,value,MaxTextExtent);
+                    next_image=ReadImage(msl_info->image_info[n],&exception);
+                    CatchException(&exception);
+                    if (next_image == (Image *) NULL)
+                      continue;
+                    if (msl_info->image[n] == (Image *) NULL)
+                      msl_info->image[n]=next_image;
+                    else
+                      {
+                        register Image
+                          *p;
+
+                        /*
+                          Link image into image list.
+                        */
+                        p=msl_info->image[n];
+                        while (p->next != (Image *) NULL)
+                          p=GetNextImageInList(p);
+                        next_image->previous=p;
+                        p->next=next_image;
+                      }
+                    break;
+                  }
+                (void) SetMSLAttributes(msl_info,keyword,value);
                 break;
               }
               default:
               {
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                (void) SetMSLAttributes(msl_info,keyword,value);
                 break;
               }
             }
           }
           break;
         }
-      if (LocaleCompare((char *) tag,"implode") == 0)
+      if (LocaleCompare((const char *) tag,"implode") == 0)
         {
           Image
             *implode_image;
@@ -3326,7 +3374,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -3334,7 +3383,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3343,7 +3392,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"amount") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3385,16 +3434,17 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'L':
     case 'l':
     {
-      if (LocaleCompare((char *) tag,"label") == 0)
+      if (LocaleCompare((const char *) tag,"label") == 0)
         break;
-      if (LocaleCompare((char *) tag, "level") == 0)
+      if (LocaleCompare((const char *) tag, "level") == 0)
       {
         double
           levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         if (attributes == (const xmlChar **) NULL)
@@ -3402,7 +3452,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
           keyword=(const char *) attributes[i++];
-          CloneString(&value,(char *) attributes[i]);
+          CloneString(&value,(const char *) attributes[i]);
           (void) CopyMagickString(key,value,MaxTextExtent);
           switch (*keyword)
           {
@@ -3411,7 +3461,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword,"black") == 0)
               {
-                levelBlack = atof( value );
+                levelBlack = StringToDouble( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -3422,7 +3472,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword,"gamma") == 0)
               {
-                levelGamma = atof( value );
+                levelGamma = StringToDouble( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -3433,7 +3483,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword,"white") == 0)
               {
-                levelWhite = atof( value );
+                levelWhite = StringToDouble( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -3460,7 +3510,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'M':
     case 'm':
     {
-      if (LocaleCompare((char *) tag,"magnify") == 0)
+      if (LocaleCompare((const char *) tag,"magnify") == 0)
         {
           Image
             *magnify_image;
@@ -3470,7 +3520,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -3478,7 +3529,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -3490,7 +3541,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=magnify_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"map") == 0)
+      if (LocaleCompare((const char *) tag,"map") == 0)
         {
           Image
             *affinity_image;
@@ -3506,7 +3557,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           affinity_image=NewImageList();
@@ -3516,7 +3568,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3545,7 +3597,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     {
                       const char
                         *attribute;
-    
+
                       attribute=GetImageProperty(msl_info->attributes[j],"id");
                       if ((attribute != (const char *) NULL)  &&
                           (LocaleCompare(attribute,value) == 0))
@@ -3573,7 +3625,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           affinity_image=DestroyImage(affinity_image);
           break;
         }
-      if (LocaleCompare((char *) tag,"matte-floodfill") == 0)
+      if (LocaleCompare((const char *) tag,"matte-floodfill") == 0)
         {
           double
             opacity;
@@ -3590,7 +3642,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           opacity=0.0;
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -3600,7 +3653,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3622,7 +3675,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"fuzz") == 0)
                     {
-                      msl_info->image[n]->fuzz=atof(value);
+                      msl_info->image[n]->fuzz=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3651,7 +3704,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"opacity") == 0)
                     {
-                      opacity=atof(value);
+                      opacity=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3663,7 +3716,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       (void) GetOneVirtualMagickPixel(msl_info->image[n],
                         geometry.x,geometry.y,&target,&exception);
                       break;
@@ -3677,7 +3730,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       (void) GetOneVirtualMagickPixel(msl_info->image[n],
                         geometry.x,geometry.y,&target,&exception);
                       break;
@@ -3696,14 +3749,14 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             }
           draw_info=CloneDrawInfo(msl_info->image_info[n],
             msl_info->draw_info[n]);
-          draw_info->fill.opacity=RoundToQuantum(opacity);
+          draw_info->fill.opacity=ClampToQuantum(opacity);
           (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel,
             draw_info,&target,geometry.x,geometry.y,
             paint_method == FloodfillMethod ? MagickFalse : MagickTrue);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
-      if (LocaleCompare((char *) tag,"median-filter") == 0)
+      if (LocaleCompare((const char *) tag,"median-filter") == 0)
         {
           Image
             *median_image;
@@ -3713,7 +3766,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -3721,7 +3775,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3744,7 +3798,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3767,7 +3821,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=median_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"minify") == 0)
+      if (LocaleCompare((const char *) tag,"minify") == 0)
         {
           Image
             *minify_image;
@@ -3777,7 +3831,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -3785,7 +3840,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
             }
@@ -3797,9 +3852,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=minify_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"msl") == 0 )
+      if (LocaleCompare((const char *) tag,"msl") == 0 )
         break;
-      if (LocaleCompare((char *) tag,"modulate") == 0)
+      if (LocaleCompare((const char *) tag,"modulate") == 0)
         {
           char
             modulate[MaxTextExtent];
@@ -3809,7 +3864,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           geometry_info.rho=100.0;
@@ -3820,7 +3876,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3829,12 +3885,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"blackness") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"brightness") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3858,7 +3914,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"hue") == 0)
                     {
-                      geometry_info.xi=atof(value);
+                      geometry_info.xi=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3870,7 +3926,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"lightness") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3882,7 +3938,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"saturation") == 0)
                     {
-                      geometry_info.sigma=atof(value);
+                      geometry_info.sigma=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3894,7 +3950,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"whiteness") == 0)
                     {
-                      geometry_info.sigma=atof(value);
+                      geometry_info.sigma=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -3919,7 +3975,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'N':
     case 'n':
     {
-      if (LocaleCompare((char *) tag,"negate") == 0)
+      if (LocaleCompare((const char *) tag,"negate") == 0)
         {
           MagickBooleanType
             gray;
@@ -3929,7 +3985,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           gray=MagickFalse;
@@ -3938,7 +3995,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -3986,14 +4043,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) NegateImageChannel(msl_info->image[n],channel,gray);
           break;
         }
-      if (LocaleCompare((char *) tag,"normalize") == 0)
+      if (LocaleCompare((const char *) tag,"normalize") == 0)
         {
           /*
             Normalize image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -4001,7 +4059,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4037,7 +4095,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'O':
     case 'o':
     {
-      if (LocaleCompare((char *) tag,"oil-paint") == 0)
+      if (LocaleCompare((const char *) tag,"oil-paint") == 0)
         {
           Image
             *paint_image;
@@ -4047,7 +4105,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -4055,7 +4114,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4078,7 +4137,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4101,7 +4160,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=paint_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"opaque") == 0)
+      if (LocaleCompare((const char *) tag,"opaque") == 0)
         {
           MagickPixelPacket
             fill_color,
@@ -4112,7 +4171,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           (void) QueryMagickColor("none",&target,&exception);
@@ -4122,7 +4182,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4152,7 +4212,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"fuzz") == 0)
                     {
-                      msl_info->image[n]->fuzz=atof(value);
+                      msl_info->image[n]->fuzz=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4176,7 +4236,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'P':
     case 'p':
     {
-      if (LocaleCompare((char *) tag,"print") == 0)
+      if (LocaleCompare((const char *) tag,"print") == 0)
         {
           if (attributes == (const xmlChar **) NULL)
             break;
@@ -4184,7 +4244,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             keyword=(const char *) attributes[i++];
             attribute=InterpretImageProperties(msl_info->image_info[n],
-              msl_info->attributes[n],(char *) attributes[i]);
+              msl_info->attributes[n],(const char *) attributes[i]);
             CloneString(&value,attribute);
             switch (*keyword)
             {
@@ -4208,12 +4268,113 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           }
           break;
         }
+        if (LocaleCompare((const char *) tag, "profile") == 0)
+          {
+            if (msl_info->image[n] == (Image *) NULL)
+              {
+                ThrowMSLException(OptionError,"NoImagesDefined",
+                  (const char *) tag);
+                break;
+              }
+            if (attributes == (const xmlChar **) NULL)
+              break;
+            for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
+            {
+              const char
+                *name;
+
+              const StringInfo
+                *profile;
+
+              Image
+                *profile_image;
+
+              ImageInfo
+                *profile_info;
+
+              keyword=(const char *) attributes[i++];
+              attribute=InterpretImageProperties(msl_info->image_info[n],
+                msl_info->attributes[n],(const char *) attributes[i]);
+              CloneString(&value,attribute);
+              if (*keyword == '+')
+                {
+                  /*
+                    Remove a profile from the image.
+                  */
+                  (void) ProfileImage(msl_info->image[n],keyword,
+                    (const unsigned char *) NULL,0,MagickTrue);
+                  continue;
+                }
+              /*
+                Associate a profile with the image.
+              */
+              profile_info=CloneImageInfo(msl_info->image_info[n]);
+              profile=GetImageProfile(msl_info->image[n],"iptc");
+              if (profile != (StringInfo *) NULL)
+                profile_info->profile=(void *) CloneStringInfo(profile);
+              profile_image=GetImageCache(profile_info,keyword,&exception);
+              profile_info=DestroyImageInfo(profile_info);
+              if (profile_image == (Image *) NULL)
+                {
+                  char
+                    name[MaxTextExtent],
+                    filename[MaxTextExtent];
+
+                  register char
+                    *p;
+
+                  StringInfo
+                    *profile;
+
+                  (void) CopyMagickString(filename,keyword,MaxTextExtent);
+                  (void) CopyMagickString(name,keyword,MaxTextExtent);
+                  for (p=filename; *p != '\0'; p++)
+                    if ((*p == ':') && (IsPathDirectory(keyword) < 0) &&
+                        (IsPathAccessible(keyword) == MagickFalse))
+                      {
+                        register char
+                          *q;
+
+                        /*
+                          Look for profile name (e.g. name:profile).
+                        */
+                        (void) CopyMagickString(name,filename,(size_t)
+                          (p-filename+1));
+                        for (q=filename; *q != '\0'; q++)
+                          *q=(*++p);
+                        break;
+                      }
+                  profile=FileToStringInfo(filename,~0UL,&exception);
+                  if (profile != (StringInfo *) NULL)
+                    {
+                      (void) ProfileImage(msl_info->image[n],name,
+                        GetStringInfoDatum(profile),(size_t)
+                        GetStringInfoLength(profile),MagickFalse);
+                      profile=DestroyStringInfo(profile);
+                    }
+                  continue;
+                }
+              ResetImageProfileIterator(profile_image);
+              name=GetNextImageProfile(profile_image);
+              while (name != (const char *) NULL)
+              {
+                profile=GetImageProfile(profile_image,name);
+                if (profile != (StringInfo *) NULL)
+                  (void) ProfileImage(msl_info->image[n],name,
+                    GetStringInfoDatum(profile),(size_t)
+                    GetStringInfoLength(profile),MagickFalse);
+                name=GetNextImageProfile(profile_image);
+              }
+              profile_image=DestroyImage(profile_image);
+            }
+            break;
+          }
       ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag);
     }
     case 'Q':
     case 'q':
     {
-      if (LocaleCompare((char *) tag,"quantize") == 0)
+      if (LocaleCompare((const char *) tag,"quantize") == 0)
         {
           QuantizeInfo
             quantize_info;
@@ -4223,7 +4384,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           GetQuantizeInfo(&quantize_info);
@@ -4232,7 +4394,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4241,7 +4403,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"colors") == 0)
                     {
-                      quantize_info.number_colors=atol(value);
+                      quantize_info.number_colors=StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"colorspace") == 0)
@@ -4297,7 +4459,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"treedepth") == 0)
                     {
-                      quantize_info.tree_depth=atol(value);
+                      quantize_info.tree_depth=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4315,7 +4477,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) QuantizeImage(&quantize_info,msl_info->image[n]);
           break;
         }
-      if (LocaleCompare((char *) tag,"query-font-metrics") == 0)
+      if (LocaleCompare((const char *) tag,"query-font-metrics") == 0)
         {
           char
             text[MaxTextExtent];
@@ -4339,7 +4501,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4472,7 +4634,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"pointsize") == 0)
                     {
-                      draw_info->pointsize=atof(value);
+                      draw_info->pointsize=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4484,7 +4646,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"rotate") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
                       affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
                       affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
@@ -4509,13 +4671,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"skewX") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.ry=cos(DegreesToRadians(fmod(angle,360.0)));
                       break;
                     }
                   if (LocaleCompare(keyword,"skewY") == 0)
                     {
-                      angle=atof(value);
+                      angle=StringToDouble(value);
                       affine.rx=cos(DegreesToRadians(fmod(angle,360.0)));
                       break;
                     }
@@ -4537,7 +4699,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=atol(value);
+                      draw_info->stroke_width=StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -4593,7 +4755,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"weight") == 0)
                     {
-                      draw_info->weight=atol(value);
+                      draw_info->weight=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4605,7 +4767,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4617,7 +4779,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4632,17 +4794,18 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               }
             }
-          (void) FormatMagickString(text,MaxTextExtent,"%lux%lu%+ld%+ld",
-            geometry.width,geometry.height,geometry.x,geometry.y);
+          (void) FormatMagickString(text,MaxTextExtent,
+            "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double)
+            geometry.height,(double) geometry.x,(double) geometry.y);
           CloneString(&draw_info->geometry,text);
-          draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
-          draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
-          draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
-          draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
-          draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
-            current.tx;
-          draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
-            current.ty;
+          draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx;
+          draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx;
+          draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy;
+          draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy;
+          draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+
+            affine.tx;
+          draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+
+            affine.ty;
           status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics);
           if (status != MagickFalse)
             {
@@ -4650,10 +4813,10 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 *image;
 
               image=msl_info->attributes[n];
-              FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x","%g",
-                metrics.pixels_per_em.x);
-              FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y","%g",
-                metrics.pixels_per_em.y);
+              FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x",
+                "%g",metrics.pixels_per_em.x);
+              FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y",
+                "%g",metrics.pixels_per_em.y);
               FormatImageProperty(image,"msl:font-metrics.ascent","%g",
                 metrics.ascent);
               FormatImageProperty(image,"msl:font-metrics.descent","%g",
@@ -4685,7 +4848,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'R':
     case 'r':
     {
-      if (LocaleCompare((char *) tag,"raise") == 0)
+      if (LocaleCompare((const char *) tag,"raise") == 0)
         {
           MagickBooleanType
             raise;
@@ -4695,7 +4858,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           raise=MagickFalse;
@@ -4705,7 +4869,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4729,7 +4893,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=atol(value);
+                      geometry.height=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4758,7 +4922,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4776,7 +4940,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) RaiseImage(msl_info->image[n],&geometry,raise);
           break;
         }
-      if (LocaleCompare((char *) tag,"read") == 0)
+      if (LocaleCompare((const char *) tag,"read") == 0)
         {
           if (attributes == (const xmlChar **) NULL)
             break;
@@ -4784,7 +4948,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             keyword=(const char *) attributes[i++];
             CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-              msl_info->attributes[n],(char *) attributes[i]));
+              msl_info->attributes[n],(const char *) attributes[i]));
             switch (*keyword)
             {
               case 'F':
@@ -4804,58 +4968,19 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     AppendImageToList(&msl_info->image[n],image);
                     break;
                   }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-                break;
-              }
-              case 'G':
-              case 'g':
-              {
-                if (LocaleCompare(keyword,"gravity") == 0)
-                  {
-                    option=ParseMagickOption(MagickGravityOptions,MagickFalse,
-                      value);
-                    if (option < 0)
-                      ThrowMSLException(OptionError,"UnrecognizedGravityType",
-                        value);
-                    (void) SetImageOption(msl_info->image_info[n],keyword,
-                      value);
-                    break;
-                  }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-                break;
-              }
-              case 'P':
-              case 'p':
-              {
-                if (LocaleCompare(keyword,"pointsize") == 0)
-                  {
-                    msl_info->image_info[n]->pointsize=atof(value);
-                    break;
-                  }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-                break;
-              }
-              case 'S':
-              case 's':
-              {
-                if (LocaleCompare(keyword,"size") == 0)
-                  {
-                    msl_info->image_info[n]->size=AcquireString(value);
-                    break;
-                  }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                (void) SetMSLAttributes(msl_info,keyword,value);
                 break;
               }
               default:
               {
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                (void) SetMSLAttributes(msl_info,keyword,value);
                 break;
               }
             }
           }
           break;
         }
-      if (LocaleCompare((char *) tag,"reduce-noise") == 0)
+      if (LocaleCompare((const char *) tag,"reduce-noise") == 0)
         {
           Image
             *paint_image;
@@ -4865,7 +4990,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -4873,7 +4999,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -4896,7 +5022,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -4919,7 +5045,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=paint_image;
           break;
         }
-      else if (LocaleCompare((char *) tag,"repage") == 0)
+      else if (LocaleCompare((const char *) tag,"repage") == 0)
       {
         /* init the values */
         width=msl_info->image[n]->page.width;
@@ -4929,7 +5055,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         if (attributes == (const xmlChar **) NULL)
@@ -4938,7 +5065,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'G':
@@ -4992,7 +5119,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"height") == 0)
             {
-            height = atol( value );
+            height = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5003,7 +5130,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"width") == 0)
             {
-            width = atol( value );
+            width = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5014,7 +5141,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"x") == 0)
             {
-            x = atol( value );
+            x = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5025,7 +5152,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"y") == 0)
             {
-            y = atol( value );
+            y = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5039,13 +5166,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         }
         }
 
-         msl_info->image[n]->page.width=width;        
-         msl_info->image[n]->page.height=height;        
-         msl_info->image[n]->page.x=x;        
-         msl_info->image[n]->page.y=y;        
+         msl_info->image[n]->page.width=width;
+         msl_info->image[n]->page.height=height;
+         msl_info->image[n]->page.x=x;
+         msl_info->image[n]->page.y=y;
         break;
       }
-    else if (LocaleCompare((char *) tag,"resample") == 0)
+    else if (LocaleCompare((const char *) tag,"resample") == 0)
     {
       double
         x_resolution,
@@ -5053,7 +5180,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
       if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
       if (attributes == (const xmlChar **) NULL)
@@ -5064,14 +5192,14 @@ static void MSLStartElement(void *context,const xmlChar *tag,
       {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'b':
           {
             if (LocaleCompare(keyword,"blur") == 0)
               {
-                msl_info->image[n]->blur=atof(value);
+                msl_info->image[n]->blur=StringToDouble(value);
                 break;
               }
             ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5082,7 +5210,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             if (LocaleCompare(keyword,"geometry") == 0)
               {
-                long
+                ssize_t
                   flags;
 
                 flags=ParseGeometry(value,&geometry_info);
@@ -5100,7 +5228,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             if (LocaleCompare(keyword,"x-resolution") == 0)
               {
-                x_resolution=atof(value);
+                x_resolution=StringToDouble(value);
                 break;
               }
             ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5111,7 +5239,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             if (LocaleCompare(keyword,"y-resolution") == 0)
               {
-                y_resolution=atof(value);
+                y_resolution=StringToDouble(value);
                 break;
               }
             ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5137,10 +5265,10 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         factor=1.0;
         if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
           factor=2.54;
-        width=(unsigned long) (x_resolution*msl_info->image[n]->columns/
+        width=(size_t) (x_resolution*msl_info->image[n]->columns/
           (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
           msl_info->image[n]->x_resolution))+0.5);
-        height=(unsigned long) (y_resolution*msl_info->image[n]->rows/
+        height=(size_t) (y_resolution*msl_info->image[n]->rows/
           (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
           msl_info->image[n]->y_resolution))+0.5);
         resample_image=ResizeImage(msl_info->image[n],width,height,
@@ -5153,7 +5281,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
       }
       break;
     }
-      if (LocaleCompare((char *) tag,"resize") == 0)
+      if (LocaleCompare((const char *) tag,"resize") == 0)
         {
           double
             blur;
@@ -5169,7 +5297,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           filter=UndefinedFilter;
@@ -5179,7 +5308,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5218,7 +5347,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=(unsigned long) atol(value);
+                      geometry.height=StringToUnsignedLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5230,7 +5359,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"support") == 0)
                     {
-                      blur=atof(value);
+                      blur=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5242,7 +5371,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5265,7 +5394,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=resize_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"roll") == 0)
+      if (LocaleCompare((const char *) tag,"roll") == 0)
         {
           Image
             *roll_image;
@@ -5275,7 +5404,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           SetGeometry(msl_info->image[n],&geometry);
@@ -5284,7 +5414,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5308,7 +5438,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry.x=atol(value);
+                      geometry.x=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5320,7 +5450,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry.y=atol(value);
+                      geometry.y=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5343,7 +5473,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=roll_image;
           break;
         }
-      else if (LocaleCompare((char *) tag,"roll") == 0)
+      else if (LocaleCompare((const char *) tag,"roll") == 0)
       {
         /* init the values */
         width=msl_info->image[n]->columns;
@@ -5352,7 +5482,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         if (attributes == (const xmlChar **) NULL)
@@ -5361,7 +5492,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'G':
@@ -5380,7 +5511,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"x") == 0)
             {
-            x = atol( value );
+            x = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5391,7 +5522,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"y") == 0)
             {
-            y = atol( value );
+            y = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5421,7 +5552,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
         break;
       }
-      if (LocaleCompare((char *) tag,"rotate") == 0)
+      if (LocaleCompare((const char *) tag,"rotate") == 0)
         {
           Image
             *rotate_image;
@@ -5431,7 +5562,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -5439,7 +5571,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5448,7 +5580,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"degrees") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5485,14 +5617,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=rotate_image;
           break;
         }
-      else if (LocaleCompare((char *) tag,"rotate") == 0)
+      else if (LocaleCompare((const char *) tag,"rotate") == 0)
       {
         /* init the values */
         double  degrees = 0;
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         if (attributes == (const xmlChar **) NULL)
@@ -5501,7 +5634,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'D':
@@ -5509,7 +5642,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"degrees") == 0)
             {
-            degrees = atof( value );
+            degrees = StringToDouble( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5544,7 +5677,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'S':
     case 's':
     {
-      if (LocaleCompare((char *) tag,"sample") == 0)
+      if (LocaleCompare((const char *) tag,"sample") == 0)
         {
           Image
             *sample_image;
@@ -5554,7 +5687,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -5562,7 +5696,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5584,7 +5718,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=(unsigned long) atol(value);
+                      geometry.height=StringToUnsignedLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5596,7 +5730,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5619,7 +5753,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=sample_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"scale") == 0)
+      if (LocaleCompare((const char *) tag,"scale") == 0)
         {
           Image
             *scale_image;
@@ -5629,7 +5763,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -5637,7 +5772,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5659,7 +5794,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"height") == 0)
                     {
-                      geometry.height=(unsigned long) atol(value);
+                      geometry.height=StringToUnsignedLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5671,7 +5806,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"width") == 0)
                     {
-                      geometry.width=atol(value);
+                      geometry.width=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5694,20 +5829,21 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=scale_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"segment") == 0)
+      if (LocaleCompare((const char *) tag,"segment") == 0)
         {
           ColorspaceType
             colorspace;
 
           MagickBooleanType
             verbose;
-            
+
           /*
             Segment image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           geometry_info.rho=1.0;
@@ -5719,7 +5855,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -5728,7 +5864,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"cluster-threshold") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"colorspace") == 0)
@@ -5764,7 +5900,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"smoothing-threshold") == 0)
                     {
-                      geometry_info.sigma=atof(value);
+                      geometry_info.sigma=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -5783,11 +5919,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             geometry_info.rho,geometry_info.sigma);
           break;
         }
-      else if (LocaleCompare((char *) tag, "set") == 0)
+      else if (LocaleCompare((const char *) tag, "set") == 0)
       {
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
 
@@ -5797,140 +5934,96 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         {
           keyword=(const char *) attributes[i++];
           CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-            msl_info->attributes[n],(char *) attributes[i]));
+            msl_info->attributes[n],(const char *) attributes[i]));
           switch (*keyword)
           {
-            case 'B':
-            case 'b':
-            {
-              if (LocaleCompare(keyword,"background") == 0)
-              {
-                (void) QueryColorDatabase(value,
-                  &msl_info->image_info[n]->background_color,&exception);
-                break;
-              }
-              else if (LocaleCompare(keyword,"bordercolor") == 0)
-              {
-                (void) QueryColorDatabase(value,
-                  &msl_info->image_info[n]->border_color,&exception);
-                break;
-              }
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-              break;
-            }
             case 'C':
             case 'c':
             {
               if (LocaleCompare(keyword,"clip-mask") == 0)
-              {
-                for (j=0; j<msl_info->n;j++)
                 {
-                  const char *
-                    theAttr = GetImageProperty(msl_info->attributes[j], "id");
-                  if (theAttr && LocaleCompare(theAttr, value) == 0)
+                  for (j=0; j < msl_info->n; j++)
                   {
-                    SetImageMask( msl_info->image[n], msl_info->image[j] );
-                    break;
+                    const char
+                      *property;
+
+                    property=GetImageProperty(msl_info->attributes[j],"id");
+                    if (LocaleCompare(property,value) == 0)
+                      {
+                        SetImageMask(msl_info->image[n],msl_info->image[j]);
+                        break;
+                      }
                   }
+                  break;
                 }
-                break;
-              }
               if (LocaleCompare(keyword,"clip-path") == 0)
-              {
-                for (j=0; j<msl_info->n;j++)
                 {
-                  const char *
-                    theAttr = GetImageProperty(msl_info->attributes[j], "id");
-                  if (theAttr && LocaleCompare(theAttr, value) == 0)
+                  for (j=0; j < msl_info->n; j++)
                   {
-                    SetImageClipMask( msl_info->image[n], msl_info->image[j] );
-                    break;
+                    const char
+                      *property;
+
+                    property=GetImageProperty(msl_info->attributes[j],"id");
+                    if (LocaleCompare(property,value) == 0)
+                      {
+                        SetImageClipMask(msl_info->image[n],msl_info->image[j]);
+                        break;
+                      }
                   }
+                  break;
                 }
-                break;
-              }
-              else if (LocaleCompare(keyword, "colorspace") == 0)
-              {
-                if (LocaleCompare(value, "CMYK") == 0)
-                  SetImageType(msl_info->image[n],ColorSeparationType );
-                else if (LocaleCompare(value, "Gray") == 0)
-                  SetImageType(msl_info->image[n],GrayscaleType );
-                else if (LocaleCompare(value, "RGB") == 0)
-                  SetImageType(msl_info->image[n],TrueColorType );
-                else
-                  ThrowMSLException(OptionError,"Unrecognized colorspace",
-                    keyword);
-                break;
-              }
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+              if (LocaleCompare(keyword,"colorspace") == 0)
+                {
+                  ssize_t
+                    colorspace;
+
+                  colorspace=(ColorspaceType) ParseMagickOption(
+                    MagickColorspaceOptions,MagickFalse,keyword);
+                  if (colorspace < 0)
+                    ThrowMSLException(OptionError,"UnrecognizedColorspace",
+                      value);
+                  (void) TransformImageColorspace(msl_info->image[n],
+                    (ColorspaceType) colorspace);
+                  break;
+                }
+              (void) SetMSLAttributes(msl_info,keyword,value);
               break;
             }
             case 'D':
             case 'd':
             {
-              if (LocaleCompare(keyword, "density") == 0)
-              {
-                GeometryInfo
-                  geometry_info;
-
-                MagickStatusType
-                  flags;
-
-                (void) CloneString(&msl_info->image_info[n]->density,
-                  (char *) NULL);
-                (void) CloneString(&msl_info->image_info[n]->density,value);
-                (void) CloneString(&msl_info->draw_info[n]->density,
-                  msl_info->image_info[n]->density);
-                flags=ParseGeometry(msl_info->image_info[n]->density,
-                  &geometry_info);
-                msl_info->image[n]->x_resolution=geometry_info.rho;
-                msl_info->image[n]->y_resolution=geometry_info.sigma;
-                if ((flags & SigmaValue) == 0)
-                  msl_info->image[n]->y_resolution=
-                    msl_info->image[n]->x_resolution;
-                break;
-              }
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-              break;
-            }
-            case 'M':
-            case 'm':
-            {
-              if (LocaleCompare(keyword, "magick") == 0)
-              {
-                (void) CopyMagickString(msl_info->image_info[n]->magick,
-                  value,MaxTextExtent);
-                break;
-              }
-              else if (LocaleCompare(keyword,"mattecolor") == 0)
-              {
-                (void) QueryColorDatabase(value,
-                  &msl_info->image_info[n]->matte_color,&exception);
-                break;
-              }
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+              if (LocaleCompare(keyword,"density") == 0)
+                {
+                  flags=ParseGeometry(value,&geometry_info);
+                  msl_info->image[n]->x_resolution=geometry_info.rho;
+                  msl_info->image[n]->y_resolution=geometry_info.sigma;
+                  if ((flags & SigmaValue) == 0)
+                    msl_info->image[n]->y_resolution=
+                      msl_info->image[n]->x_resolution;
+                  break;
+                }
+              (void) SetMSLAttributes(msl_info,keyword,value);
               break;
             }
             case 'O':
             case 'o':
             {
               if (LocaleCompare(keyword, "opacity") == 0)
-              {
-                long  opac = OpaqueOpacity,
-                  len = (long) strlen( value );
-
-                if (value[len-1] == '%') {
-                  char  tmp[100];
-                  (void) CopyMagickString(tmp,value,len);
-                  opac = atol( tmp );
-                  opac = (int)(QuantumRange * ((float)opac/100));
-                } else
-                  opac = atol( value );
-                (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
-                break;
-              }
+                {
+                  ssize_t  opac = OpaqueOpacity,
+                  len = (ssize_t) strlen( value );
 
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                  if (value[len-1] == '%') {
+                    char  tmp[100];
+                    (void) CopyMagickString(tmp,value,len);
+                    opac = StringToLong( tmp );
+                    opac = (int)(QuantumRange * ((float)opac/100));
+                  } else
+                    opac = StringToLong( value );
+                  (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
+                  break;
+              }
+              (void) SetMSLAttributes(msl_info,keyword,value);
               break;
             }
             case 'P':
@@ -5955,28 +6048,30 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 if (image_option != (const char *) NULL)
                   flags=ParseAbsoluteGeometry(image_option,&geometry);
                 flags=ParseAbsoluteGeometry(value,&geometry);
-                (void) FormatMagickString(page,MaxTextExtent,"%lux%lu",
-                  geometry.width,geometry.height);
+                (void) FormatMagickString(page,MaxTextExtent,"%.20gx%.20g",
+                  (double) geometry.width,(double) geometry.height);
                 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
-                  (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld",
-                    geometry.width,geometry.height,geometry.x,geometry.y);
+                  (void) FormatMagickString(page,MaxTextExtent,
+                    "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,
+                    (double) geometry.height,(double) geometry.x,(double)
+                    geometry.y);
                 (void) SetImageOption(msl_info->image_info[n],keyword,page);
                 msl_info->image_info[n]->page=GetPageGeometry(page);
                 break;
               }
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+              (void) SetMSLAttributes(msl_info,keyword,value);
               break;
             }
             default:
             {
-              ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+              (void) SetMSLAttributes(msl_info,keyword,value);
               break;
             }
           }
         }
         break;
       }
-      if (LocaleCompare((char *) tag,"shade") == 0)
+      if (LocaleCompare((const char *) tag,"shade") == 0)
         {
           Image
             *shade_image;
@@ -5989,7 +6084,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           gray=MagickFalse;
@@ -5998,7 +6094,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6007,7 +6103,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"azimuth") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6019,7 +6115,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"elevation") == 0)
                     {
-                      geometry_info.sigma=atof(value);
+                      geometry_info.sigma=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6066,7 +6162,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=shade_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"shadow") == 0)
+      if (LocaleCompare((const char *) tag,"shadow") == 0)
         {
           Image
             *shadow_image;
@@ -6076,7 +6172,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6084,7 +6181,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6107,7 +6204,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"opacity") == 0)
                     {
-                      geometry_info.rho=atol(value);
+                      geometry_info.rho=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6119,7 +6216,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"sigma") == 0)
                     {
-                      geometry_info.sigma=atol(value);
+                      geometry_info.sigma=StringToLong(value);
                       break;
                     }
                   break;
@@ -6129,7 +6226,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry_info.xi=atof(value);
+                      geometry_info.xi=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6141,7 +6238,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry_info.psi=atol(value);
+                      geometry_info.psi=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6157,24 +6254,25 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               }
             }
           shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
-            geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
-            (geometry_info.psi+0.5),&msl_info->image[n]->exception);
+            geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
+            ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
           if (shadow_image == (Image *) NULL)
             break;
           msl_info->image[n]=DestroyImage(msl_info->image[n]);
           msl_info->image[n]=shadow_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"sharpen") == 0)
+      if (LocaleCompare((const char *) tag,"sharpen") == 0)
       {
         double  radius = 0.0,
             sigma = 1.0;
 
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",
+              (const char *) tag);
+            break;
+          }
         /*
         NOTE: sharpen can have no attributes, since we use all the defaults!
         */
@@ -6184,7 +6282,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           keyword=(const char *) attributes[i++];
           CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-            msl_info->attributes[n],(char *) attributes[i]));
+            msl_info->attributes[n],(const char *) attributes[i]));
           switch (*keyword)
           {
             case 'R':
@@ -6192,7 +6290,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword, "radius") == 0)
               {
-                radius = atof( value );
+                radius = StringToDouble( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -6203,7 +6301,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword,"sigma") == 0)
               {
-                sigma = atol( value );
+                sigma = StringToLong( value );
                 break;
               }
               ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -6233,7 +6331,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         break;
         }
       }
-      else if (LocaleCompare((char *) tag,"shave") == 0)
+      else if (LocaleCompare((const char *) tag,"shave") == 0)
       {
         /* init the values */
         width = height = 0;
@@ -6241,7 +6339,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
         if (msl_info->image[n] == (Image *) NULL)
         {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+          ThrowMSLException(OptionError,"NoImagesDefined",
+            (const char *) tag);
           break;
         }
         if (attributes == (const xmlChar **) NULL)
@@ -6250,7 +6349,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'G':
@@ -6269,7 +6368,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"height") == 0)
             {
-            height = atol( value );
+            height = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -6280,7 +6379,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"width") == 0)
             {
-            width = atol( value );
+            width = StringToLong( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -6319,7 +6418,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
         break;
       }
-      if (LocaleCompare((char *) tag,"shear") == 0)
+      if (LocaleCompare((const char *) tag,"shear") == 0)
         {
           Image
             *shear_image;
@@ -6329,7 +6428,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6337,7 +6437,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6373,7 +6473,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"x") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6385,7 +6485,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"y") == 0)
                     {
-                      geometry_info.sigma=atol(value);
+                      geometry_info.sigma=StringToLong(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6408,14 +6508,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=shear_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"signature") == 0)
+      if (LocaleCompare((const char *) tag,"signature") == 0)
         {
           /*
             Signature image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6423,7 +6524,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6438,14 +6539,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) SignatureImage(msl_info->image[n]);
           break;
         }
-      if (LocaleCompare((char *) tag,"solarize") == 0)
+      if (LocaleCompare((const char *) tag,"solarize") == 0)
         {
           /*
             Solarize image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           geometry_info.rho=QuantumRange/2.0;
@@ -6454,7 +6556,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6475,7 +6577,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"threshold") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6493,7 +6595,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           (void) SolarizeImage(msl_info->image[n],geometry_info.rho);
           break;
         }
-      if (LocaleCompare((char *) tag,"spread") == 0)
+      if (LocaleCompare((const char *) tag,"spread") == 0)
         {
           Image
             *spread_image;
@@ -6503,7 +6605,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6511,7 +6614,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6534,7 +6637,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"radius") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6557,23 +6660,24 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=spread_image;
           break;
         }
-      else if (LocaleCompare((char *) tag,"stegano") == 0)
+      else if (LocaleCompare((const char *) tag,"stegano") == 0)
       {
         Image *
           watermark = (Image*)NULL;
 
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",
+              (const char *) tag);
+            break;
+          }
         if (attributes == (const xmlChar **) NULL)
         break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'I':
@@ -6621,23 +6725,23 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         } else
           ThrowMSLException(OptionError,"MissingWatermarkImage",keyword);
       }
-      else if (LocaleCompare((char *) tag,"stereo") == 0)
+      else if (LocaleCompare((const char *) tag,"stereo") == 0)
       {
         Image *
           stereoImage = (Image*)NULL;
 
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
+            break;
+          }
         if (attributes == (const xmlChar **) NULL)
         break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'I':
@@ -6685,20 +6789,21 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         } else
           ThrowMSLException(OptionError,"Missing stereo image",keyword);
       }
-      if (LocaleCompare((char *) tag,"swap") == 0)
+      if (LocaleCompare((const char *) tag,"swap") == 0)
         {
           Image
             *p,
             *q,
             *swap;
 
-          long
+          ssize_t
             index,
             swap_index;
 
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           index=(-1);
@@ -6708,7 +6813,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6718,9 +6823,9 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                   if (LocaleCompare(keyword,"indexes") == 0)
                     {
                       flags=ParseGeometry(value,&geometry_info);
-                      index=(long) geometry_info.rho;
+                      index=(ssize_t) geometry_info.rho;
                       if ((flags & SigmaValue) == 0)
-                        swap_index=(long) geometry_info.sigma;
+                        swap_index=(ssize_t) geometry_info.sigma;
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6742,7 +6847,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           q=GetImageFromList(msl_info->image[n],swap_index);
           if ((p == (Image *) NULL) || (q == (Image *) NULL))
             {
-              ThrowMSLException(OptionError,"NoSuchImage",(char *) tag);
+              ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag);
               break;
             }
           swap=CloneImage(p,0,0,MagickTrue,&p->exception);
@@ -6751,7 +6856,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=GetFirstImageInList(q);
           break;
         }
-      if (LocaleCompare((char *) tag,"swirl") == 0)
+      if (LocaleCompare((const char *) tag,"swirl") == 0)
         {
           Image
             *swirl_image;
@@ -6761,7 +6866,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6769,7 +6875,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6778,7 +6884,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 {
                   if (LocaleCompare(keyword,"degrees") == 0)
                     {
-                      geometry_info.rho=atof(value);
+                      geometry_info.rho=StringToDouble(value);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -6815,14 +6921,15 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           msl_info->image[n]=swirl_image;
           break;
         }
-      if (LocaleCompare((char *) tag,"sync") == 0)
+      if (LocaleCompare((const char *) tag,"sync") == 0)
         {
           /*
             Sync image.
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes != (const xmlChar **) NULL)
@@ -6830,7 +6937,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6850,7 +6957,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'T':
     case 't':
     {
-      if (LocaleCompare((char *) tag,"map") == 0)
+      if (LocaleCompare((const char *) tag,"map") == 0)
         {
           Image
             *texture_image;
@@ -6860,7 +6967,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           */
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           texture_image=NewImageList();
@@ -6869,7 +6977,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               keyword=(const char *) attributes[i++];
               attribute=InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]);
+                msl_info->attributes[n],(const char *) attributes[i]);
               CloneString(&value,attribute);
               switch (*keyword)
               {
@@ -6881,7 +6989,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     {
                       const char
                         *attribute;
-    
+
                       attribute=GetImageProperty(msl_info->attributes[j],"id");
                       if ((attribute != (const char *) NULL)  &&
                           (LocaleCompare(attribute,value) == 0))
@@ -6905,23 +7013,23 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           texture_image=DestroyImage(texture_image);
           break;
         }
-      else if (LocaleCompare((char *) tag,"threshold") == 0)
+      else if (LocaleCompare((const char *) tag,"threshold") == 0)
       {
         /* init the values */
         double  threshold = 0;
 
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
+            break;
+          }
         if (attributes == (const xmlChar **) NULL)
         break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
         keyword=(const char *) attributes[i++];
         CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-          msl_info->attributes[n],(char *) attributes[i]));
+          msl_info->attributes[n],(const char *) attributes[i]));
         switch (*keyword)
         {
           case 'T':
@@ -6929,7 +7037,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
           if (LocaleCompare(keyword,"threshold") == 0)
             {
-            threshold = atof( value );
+            threshold = StringToDouble( value );
             break;
             }
           ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -6948,25 +7056,25 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         */
         {
         BilevelImageChannel(msl_info->image[n],
-          (ChannelType) ((long) (AllChannels &~ (long) OpacityChannel)),
+          (ChannelType) ((ssize_t) (AllChannels &~ (ssize_t) OpacityChannel)),
           threshold);
         break;
         }
       }
-      else if (LocaleCompare((char *) tag, "transparent") == 0)
+      else if (LocaleCompare((const char *) tag, "transparent") == 0)
       {
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
+            break;
+          }
         if (attributes == (const xmlChar **) NULL)
           break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
           keyword=(const char *) attributes[i++];
           CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-                msl_info->attributes[n],(char *) attributes[i]));
+            msl_info->attributes[n],(const char *) attributes[i]));
           switch (*keyword)
           {
             case 'C':
@@ -6994,13 +7102,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         }
         break;
       }
-      else if (LocaleCompare((char *) tag, "trim") == 0)
+      else if (LocaleCompare((const char *) tag, "trim") == 0)
       {
         if (msl_info->image[n] == (Image *) NULL)
-        {
-          ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
-          break;
-        }
+          {
+            ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
+            break;
+          }
 
         /* no attributes here */
 
@@ -7028,11 +7136,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
     case 'W':
     case 'w':
     {
-      if (LocaleCompare((char *) tag,"write") == 0)
+      if (LocaleCompare((const char *) tag,"write") == 0)
         {
           if (msl_info->image[n] == (Image *) NULL)
             {
-              ThrowMSLException(OptionError,"NoImagesDefined",(char *) tag);
+              ThrowMSLException(OptionError,"NoImagesDefined",
+                (const char *) tag);
               break;
             }
           if (attributes == (const xmlChar **) NULL)
@@ -7041,7 +7150,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             keyword=(const char *) attributes[i++];
             CloneString(&value,InterpretImageProperties(msl_info->image_info[n],
-              msl_info->attributes[n],(char *) attributes[i]));
+              msl_info->attributes[n],(const char *) attributes[i]));
             switch (*keyword)
             {
               case 'F':
@@ -7053,23 +7162,11 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                       MaxTextExtent);
                     break;
                   }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-              }
-              case 'Q':
-              case 'q':
-              {
-                if (LocaleCompare(keyword,"quality") == 0)
-                  {
-                    msl_info->image_info[n]->quality=atol(value);
-                    msl_info->image[n]->quality=
-                      msl_info->image_info[n]->quality;
-                    break;
-                  }
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                (void) SetMSLAttributes(msl_info,keyword,value);
               }
               default:
               {
-                ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+                (void) SetMSLAttributes(msl_info,keyword,value);
                 break;
               }
             }
@@ -7096,7 +7193,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
 static void MSLEndElement(void *context,const xmlChar *tag)
 {
-  long
+  ssize_t
     n;
 
   MSLInfo
@@ -7114,7 +7211,7 @@ static void MSLEndElement(void *context,const xmlChar *tag)
     case 'C':
     case 'c':
     {
-      if (LocaleCompare((char *) tag,"comment") == 0 )
+      if (LocaleCompare((const char *) tag,"comment") == 0 )
         {
           (void) DeleteImageProperty(msl_info->image[n],"comment");
           if (msl_info->content == (char *) NULL)
@@ -7129,11 +7226,11 @@ static void MSLEndElement(void *context,const xmlChar *tag)
     case 'G':
     case 'g':
     {
-      if (LocaleCompare((char *) tag, "group") == 0 )
+      if (LocaleCompare((const char *) tag, "group") == 0 )
       {
         if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
         {
-          long  i = (long)
+          ssize_t  i = (ssize_t)
             (msl_info->group_info[msl_info->number_groups-1].numImages);
           while ( i-- )
           {
@@ -7151,14 +7248,14 @@ static void MSLEndElement(void *context,const xmlChar *tag)
     case 'I':
     case 'i':
     {
-      if (LocaleCompare((char *) tag, "image") == 0)
+      if (LocaleCompare((const char *) tag, "image") == 0)
         MSLPopImage(msl_info);
        break;
     }
     case 'L':
     case 'l':
     {
-      if (LocaleCompare((char *) tag,"label") == 0 )
+      if (LocaleCompare((const char *) tag,"label") == 0 )
         {
           (void) DeleteImageProperty(msl_info->image[n],"label");
           if (msl_info->content == (char *) NULL)
@@ -7173,7 +7270,7 @@ static void MSLEndElement(void *context,const xmlChar *tag)
     case 'M':
     case 'm':
     {
-      if (LocaleCompare((char *) tag, "msl") == 0 )
+      if (LocaleCompare((const char *) tag, "msl") == 0 )
       {
         /*
           This our base element.
@@ -7198,7 +7295,7 @@ static void MSLCharacters(void *context,const xmlChar *c,int length)
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -7396,8 +7493,8 @@ static void MSLExternalSubset(void *context,const xmlChar *name,
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
     "  SAX.externalSubset(%s %s %s)",name,
-    (external_id != (const xmlChar *) NULL ? (char *) external_id : " "),
-    (system_id != (const xmlChar *) NULL ? (char *) system_id : " "));
+    (external_id != (const xmlChar *) NULL ? (const char *) external_id : " "),
+    (system_id != (const xmlChar *) NULL ? (const char *) system_id : " "));
   msl_info=(MSLInfo *) context;
   parser=msl_info->parser;
   if (((external_id == NULL) && (system_id == NULL)) ||
@@ -7449,38 +7546,6 @@ static void MSLExternalSubset(void *context,const xmlChar *name,
 static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **image,
   ExceptionInfo *exception)
 {
-  xmlSAXHandler
-    SAXModules =
-    {
-      MSLInternalSubset,
-      MSLIsStandalone,
-      MSLHasInternalSubset,
-      MSLHasExternalSubset,
-      MSLResolveEntity,
-      MSLGetEntity,
-      MSLEntityDeclaration,
-      MSLNotationDeclaration,
-      MSLAttributeDeclaration,
-      MSLElementDeclaration,
-      MSLUnparsedEntityDeclaration,
-      MSLSetDocumentLocator,
-      MSLStartDocument,
-      MSLEndDocument,
-      MSLStartElement,
-      MSLEndElement,
-      MSLReference,
-      MSLCharacters,
-      MSLIgnorableWhitespace,
-      MSLProcessingInstructions,
-      MSLComment,
-      MSLWarning,
-      MSLError,
-      MSLError,
-      MSLGetParameterEntity,
-      MSLCDataBlock,
-      MSLExternalSubset
-    };
-
   char
     message[MaxTextExtent];
 
@@ -7490,14 +7555,17 @@ static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **im
   int
     status;
 
-  long
+  ssize_t
     n;
 
   MSLInfo
     msl_info;
 
+  xmlSAXHandler
+    sax_modules;
+
   xmlSAXHandlerPtr
-    SAXHandler;
+    sax_handler;
 
   /*
     Open image file.
@@ -7505,7 +7573,8 @@ static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **im
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   if (image_info->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image_info->filename);
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      image_info->filename);
   assert(image != (Image **) NULL);
   msl_image=AcquireImage(image_info);
   status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
@@ -7548,12 +7617,40 @@ static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **im
   if (*image != (Image *) NULL)
     MSLPushImage(&msl_info,*image);
   (void) xmlSubstituteEntitiesDefault(1);
-  SAXHandler=(&SAXModules);
-  msl_info.parser=xmlCreatePushParserCtxt(SAXHandler,&msl_info,(char *) NULL,0,
+  (void) ResetMagickMemory(&sax_modules,0,sizeof(sax_modules));
+  sax_modules.internalSubset=MSLInternalSubset;
+  sax_modules.isStandalone=MSLIsStandalone;
+  sax_modules.hasInternalSubset=MSLHasInternalSubset;
+  sax_modules.hasExternalSubset=MSLHasExternalSubset;
+  sax_modules.resolveEntity=MSLResolveEntity;
+  sax_modules.getEntity=MSLGetEntity;
+  sax_modules.entityDecl=MSLEntityDeclaration;
+  sax_modules.notationDecl=MSLNotationDeclaration;
+  sax_modules.attributeDecl=MSLAttributeDeclaration;
+  sax_modules.elementDecl=MSLElementDeclaration;
+  sax_modules.unparsedEntityDecl=MSLUnparsedEntityDeclaration;
+  sax_modules.setDocumentLocator=MSLSetDocumentLocator;
+  sax_modules.startDocument=MSLStartDocument;
+  sax_modules.endDocument=MSLEndDocument;
+  sax_modules.startElement=MSLStartElement;
+  sax_modules.endElement=MSLEndElement;
+  sax_modules.reference=MSLReference;
+  sax_modules.characters=MSLCharacters;
+  sax_modules.ignorableWhitespace=MSLIgnorableWhitespace;
+  sax_modules.processingInstruction=MSLProcessingInstructions;
+  sax_modules.comment=MSLComment;
+  sax_modules.warning=MSLWarning;
+  sax_modules.error=MSLError;
+  sax_modules.fatalError=MSLError;
+  sax_modules.getParameterEntity=MSLGetParameterEntity;
+  sax_modules.cdataBlock=MSLCDataBlock;
+  sax_modules.externalSubset=MSLExternalSubset;
+  sax_handler=(&sax_modules);
+  msl_info.parser=xmlCreatePushParserCtxt(sax_handler,&msl_info,(char *) NULL,0,
     msl_image->filename);
   while (ReadBlobString(msl_image,message) != (char *) NULL)
   {
-    n=(long) strlen(message);
+    n=(ssize_t) strlen(message);
     if (n == 0)
       continue;
     status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
@@ -7572,7 +7669,9 @@ static MagickBooleanType ProcessMSLScript(const ImageInfo *image_info,Image **im
     msl_info.group_info);
   if (*image == (Image *) NULL)
     *image=(*msl_info.image);
-  return((MagickBooleanType) ((*msl_info.image)->exception.severity == UndefinedException));
+  if ((*msl_info.image)->exception.severity != UndefinedException)
+    return(MagickFalse);
+  return(MagickTrue);
 }
 
 static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
@@ -7616,10 +7715,10 @@ static Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception)
 %
 %  The format of the RegisterMSLImage method is:
 %
-%      unsigned long RegisterMSLImage(void)
+%      size_t RegisterMSLImage(void)
 %
 */
-ModuleExport unsigned long RegisterMSLImage(void)
+ModuleExport size_t RegisterMSLImage(void)
 {
   MagickInfo
     *entry;
@@ -7635,6 +7734,298 @@ ModuleExport unsigned long RegisterMSLImage(void)
   return(MagickImageCoderSignature);
 }
 \f
+#if defined(MAGICKCORE_XML_DELEGATE)
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   S e t M S L A t t r i b u t e s                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  SetMSLAttributes() ...
+%
+%  The format of the SetMSLAttributes method is:
+%
+%      MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,
+%        const char *keyword,const char *value)
+%
+%  A description of each parameter follows:
+%
+%    o msl_info: the MSL info.
+%
+%    o keyword: the keyword.
+%
+%    o value: the value.
+%
+*/
+static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
+  const char *value)
+{
+  Image
+    *attributes;
+
+  DrawInfo
+    *draw_info;
+
+  ExceptionInfo
+    *exception;
+
+  GeometryInfo
+    geometry_info;
+
+  Image
+    *image;
+
+  ImageInfo
+    *image_info;
+
+  int
+    flags;
+
+  ssize_t
+    n;
+
+  assert(msl_info != (MSLInfo *) NULL);
+  if (keyword == (const char *) NULL)
+    return(MagickTrue);
+  if (value == (const char *) NULL)
+    return(MagickTrue);
+  exception=msl_info->exception;
+  n=msl_info->n;
+  attributes=msl_info->attributes[n];
+  image_info=msl_info->image_info[n];
+  draw_info=msl_info->draw_info[n];
+  image=msl_info->image[n];
+  switch (*keyword)
+  {
+    case 'A':
+    case 'a':
+    {
+      if (LocaleCompare(keyword,"adjoin") == 0)
+        {
+          ssize_t
+            adjoin;
+
+          adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
+          if (adjoin < 0)
+            ThrowMSLException(OptionError,"UnrecognizedType",value);
+          image_info->adjoin=(MagickBooleanType) adjoin;
+          break;
+        }
+      if (LocaleCompare(keyword,"alpha") == 0)
+        {
+          ssize_t
+            alpha;
+
+          alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
+          if (alpha < 0)
+            ThrowMSLException(OptionError,"UnrecognizedType",value);
+          if (image != (Image *) NULL)
+            (void) SetImageAlphaChannel(image,(AlphaChannelType) alpha);
+          break;
+        }
+      if (LocaleCompare(keyword,"antialias") == 0)
+        {
+          ssize_t
+            antialias;
+
+          antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
+          if (antialias < 0)
+            ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
+          image_info->antialias=(MagickBooleanType) antialias;
+          break;
+        }
+      if (LocaleCompare(keyword,"area-limit") == 0)
+        {
+          MagickSizeType
+            limit;
+
+          limit=MagickResourceInfinity;
+          if (LocaleCompare(value,"unlimited") != 0)
+            limit=(MagickSizeType) SiPrefixToDouble(value,100.0);
+          (void) SetMagickResourceLimit(AreaResource,limit);
+          break;
+        }
+      if (LocaleCompare(keyword,"attenuate") == 0)
+        {
+          (void) SetImageOption(image_info,keyword,value);
+          break;
+        }
+      if (LocaleCompare(keyword,"authenticate") == 0)
+        {
+          (void) CloneString(&image_info->density,value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'B':
+    case 'b':
+    {
+      if (LocaleCompare(keyword,"background") == 0)
+        {
+          (void) QueryColorDatabase(value,&image_info->background_color,
+            exception);
+          break;
+        }
+      if (LocaleCompare(keyword,"bias") == 0)
+        {
+          if (image == (Image *) NULL)
+            break;
+          image->bias=SiPrefixToDouble(value,QuantumRange);
+          break;
+        }
+      if (LocaleCompare(keyword,"blue-primary") == 0)
+        {
+          if (image == (Image *) NULL)
+            break;
+          flags=ParseGeometry(value,&geometry_info);
+          image->chromaticity.blue_primary.x=geometry_info.rho;
+          image->chromaticity.blue_primary.y=geometry_info.sigma;
+          if ((flags & SigmaValue) == 0)
+            image->chromaticity.blue_primary.y=
+              image->chromaticity.blue_primary.x;
+          break;
+        }
+      if (LocaleCompare(keyword,"bordercolor") == 0)
+        {
+          (void) QueryColorDatabase(value,&image_info->border_color,
+            exception);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'D':
+    case 'd':
+    {
+      if (LocaleCompare(keyword,"density") == 0)
+        {
+          (void) CloneString(&image_info->density,value);
+          (void) CloneString(&draw_info->density,value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'F':
+    case 'f':
+    {
+      if (LocaleCompare(keyword,"fill") == 0)
+        {
+          (void) QueryColorDatabase(value,&draw_info->fill,exception);
+          (void) SetImageOption(image_info,keyword,value);
+          break;
+        }
+      if (LocaleCompare(keyword,"filename") == 0)
+        {
+          (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'G':
+    case 'g':
+    {
+      if (LocaleCompare(keyword,"gravity") == 0)
+        {
+          ssize_t
+            gravity;
+
+          gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
+          if (gravity < 0)
+            ThrowMSLException(OptionError,"UnrecognizedGravityType",value);
+          (void) SetImageOption(image_info,keyword,value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'I':
+    case 'i':
+    {
+      if (LocaleCompare(keyword,"id") == 0)
+        {
+          (void) SetImageProperty(attributes,keyword,value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'M':
+    case 'm':
+    {
+      if (LocaleCompare(keyword,"magick") == 0)
+        {
+          (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
+          break;
+        }
+      if (LocaleCompare(keyword,"mattecolor") == 0)
+        {
+          (void) QueryColorDatabase(value,&image_info->matte_color,
+            exception);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'P':
+    case 'p':
+    {
+      if (LocaleCompare(keyword,"pointsize") == 0)
+        {
+          image_info->pointsize=StringToDouble(value);
+          draw_info->pointsize=StringToDouble(value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    case 'Q':
+    case 'q':
+    {
+      if (LocaleCompare(keyword,"quality") == 0)
+        {
+          image_info->quality=StringToLong(value);
+          if (image == (Image *) NULL)
+            break;
+          image->quality=StringToLong(value);
+          break;
+        }
+      break;
+    }
+    case 'S':
+    case 's':
+    {
+      if (LocaleCompare(keyword,"size") == 0)
+        {
+          (void) CloneString(&image_info->size,value);
+          break;
+        }
+      if (LocaleCompare(keyword,"stroke") == 0)
+        {
+          (void) QueryColorDatabase(value,&draw_info->stroke,exception);
+          (void) SetImageOption(image_info,keyword,value);
+          break;
+        }
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+    default:
+    {
+      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
+      break;
+    }
+  }
+  return(MagickTrue);
+}
+#endif
+\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %