]> granicus.if.org Git - imagemagick/blobdiff - coders/msl.c
(no commit message)
[imagemagick] / coders / msl.c
index 539fa9783fc36bbbdfe96a174b7f19ed92d6d18a..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;
 
@@ -190,6 +195,54 @@ static MagickBooleanType
 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
@@ -492,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);
@@ -576,7 +629,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
   int
     flags;
 
-  long
+  ssize_t
     option,
     j,
     n,
@@ -589,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;
 
@@ -846,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",
@@ -858,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))));
@@ -883,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;
@@ -913,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)
@@ -969,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",
@@ -981,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",
@@ -993,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",
@@ -1008,17 +1061,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) AnnotateImage(msl_info->image[n],draw_info);
           draw_info=DestroyDrawInfo(draw_info);
           break;
@@ -1144,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",
@@ -1156,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",
@@ -1254,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",
@@ -1266,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",
@@ -1394,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);
@@ -1405,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);
@@ -1480,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",
@@ -1492,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",
@@ -1504,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",
@@ -1516,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",
@@ -1593,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",
@@ -1622,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;
@@ -1636,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;
@@ -1849,11 +1903,11 @@ 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
@@ -1862,7 +1916,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                       CacheView
                         *composite_view;
 
-                      opacity=QuantumRange-atol(value);
+                      opacity=QuantumRange-StringToLong(value);
                       if (compose != DissolveCompositeOp)
                         {
                           (void) SetImageOpacity(composite_image,(Quantum)
@@ -1874,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++)
+                      for (y=0; y < (ssize_t) composite_image->rows ; y++)
                       {
-                        q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
+                        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)
@@ -1899,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;
                     }
@@ -1930,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,
@@ -1953,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;
@@ -1967,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;
@@ -1986,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)
@@ -1998,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);
@@ -2104,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",
@@ -2116,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",
@@ -2128,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",
@@ -2140,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",
@@ -2165,7 +2220,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
         }
       if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
         {
-          long
+          ssize_t
             display;
 
           /*
@@ -2192,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",
@@ -2436,7 +2491,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",
@@ -2448,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))));
@@ -2473,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;
                     }
@@ -2501,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)
@@ -2557,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",
@@ -2569,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",
@@ -2581,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",
@@ -2596,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;
@@ -2658,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",
@@ -2723,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",
@@ -2735,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",
@@ -2993,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",
@@ -3005,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",
@@ -3017,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",
@@ -3029,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",
@@ -3044,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,
@@ -3097,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",
@@ -3130,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",
@@ -3142,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",
@@ -3209,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;
                   }
@@ -3221,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;
                   }
@@ -3336,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",
@@ -3405,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);
@@ -3416,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);
@@ -3427,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);
@@ -3619,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",
@@ -3648,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",
@@ -3660,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;
@@ -3674,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;
@@ -3693,7 +3749,7 @@ 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);
@@ -3742,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",
@@ -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",
@@ -4081,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",
@@ -4156,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",
@@ -4212,6 +4268,107 @@ 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':
@@ -4246,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)
@@ -4302,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",
@@ -4477,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",
@@ -4489,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))));
@@ -4514,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;
                     }
@@ -4542,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)
@@ -4598,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",
@@ -4610,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",
@@ -4622,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",
@@ -4637,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)
             {
@@ -4655,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",
@@ -4735,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",
@@ -4764,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",
@@ -4810,51 +4968,12 @@ 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;
               }
             }
@@ -4903,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",
@@ -5000,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);
@@ -5011,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);
@@ -5022,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);
@@ -5033,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);
@@ -5080,7 +5199,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
           {
             if (LocaleCompare(keyword,"blur") == 0)
               {
-                msl_info->image[n]->blur=atof(value);
+                msl_info->image[n]->blur=StringToDouble(value);
                 break;
               }
             ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -5091,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);
@@ -5109,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);
@@ -5120,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);
@@ -5146,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,
@@ -5228,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",
@@ -5240,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",
@@ -5252,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",
@@ -5319,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",
@@ -5331,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",
@@ -5392,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);
@@ -5403,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);
@@ -5461,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",
@@ -5523,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);
@@ -5599,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",
@@ -5611,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",
@@ -5675,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",
@@ -5687,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",
@@ -5745,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)
@@ -5781,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",
@@ -5855,13 +5974,13 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               if (LocaleCompare(keyword,"colorspace") == 0)
                 {
-                  long
+                  ssize_t
                     colorspace;
 
                   colorspace=(ColorspaceType) ParseMagickOption(
                     MagickColorspaceOptions,MagickFalse,keyword);
                   if (colorspace < 0)
-                    ThrowMSLException(OptionError,"Unrecognized colorspace",
+                    ThrowMSLException(OptionError,"UnrecognizedColorspace",
                       value);
                   (void) TransformImageColorspace(msl_info->image[n],
                     (ColorspaceType) colorspace);
@@ -5891,16 +6010,16 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             {
               if (LocaleCompare(keyword, "opacity") == 0)
                 {
-                  long  opac = OpaqueOpacity,
-                  len = (long) strlen( value );
+                  ssize_t  opac = OpaqueOpacity,
+                  len = (ssize_t) strlen( value );
 
                   if (value[len-1] == '%') {
                     char  tmp[100];
                     (void) CopyMagickString(tmp,value,len);
-                    opac = atol( tmp );
+                    opac = StringToLong( tmp );
                     opac = (int)(QuantumRange * ((float)opac/100));
                   } else
-                    opac = atol( value );
+                    opac = StringToLong( value );
                   (void) SetImageOpacity( msl_info->image[n], (Quantum) opac );
                   break;
               }
@@ -5929,11 +6048,13 @@ 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;
@@ -5982,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",
@@ -5994,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",
@@ -6083,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",
@@ -6095,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;
@@ -6105,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",
@@ -6117,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",
@@ -6133,8 +6254,8 @@ 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]);
@@ -6169,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);
@@ -6180,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);
@@ -6247,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);
@@ -6258,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);
@@ -6352,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",
@@ -6364,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",
@@ -6456,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",
@@ -6516,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",
@@ -6675,7 +6796,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
             *q,
             *swap;
 
-          long
+          ssize_t
             index,
             swap_index;
 
@@ -6702,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",
@@ -6763,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",
@@ -6916,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);
@@ -6935,7 +7056,7 @@ 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;
         }
@@ -7041,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;
               }
             }
@@ -7084,7 +7193,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
 
 static void MSLEndElement(void *context,const xmlChar *tag)
 {
-  long
+  ssize_t
     n;
 
   MSLInfo
@@ -7121,7 +7230,7 @@ static void MSLEndElement(void *context,const xmlChar *tag)
       {
         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-- )
           {
@@ -7186,7 +7295,7 @@ static void MSLCharacters(void *context,const xmlChar *c,int length)
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -7437,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];
 
@@ -7478,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.
@@ -7493,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);
@@ -7536,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);
@@ -7560,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)
@@ -7604,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;
@@ -7623,6 +7734,7 @@ ModuleExport unsigned long RegisterMSLImage(void)
   return(MagickImageCoderSignature);
 }
 \f
+#if defined(MAGICKCORE_XML_DELEGATE)
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -7653,16 +7765,28 @@ ModuleExport unsigned long RegisterMSLImage(void)
 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;
 
-  long
+  int
+    flags;
+
+  ssize_t
     n;
 
   assert(msl_info != (MSLInfo *) NULL);
@@ -7672,10 +7796,73 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
     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':
     {
@@ -7685,6 +7872,25 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
             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,
@@ -7712,6 +7918,29 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
       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);
@@ -7722,8 +7951,7 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
     {
       if (LocaleCompare(keyword,"id") == 0)
         {
-          (void) SetImageProperty(msl_info->attributes[n],keyword,NULL);
-          (void) SetImageProperty(msl_info->attributes[n],keyword,value);
+          (void) SetImageProperty(attributes,keyword,value);
           break;
         }
       ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -7737,12 +7965,6 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
           (void) CopyMagickString(image_info->magick,value,MaxTextExtent);
           break;
         }
-      ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
-      break;
-    }
-    case 'P':
-    case 'p':
-    {
       if (LocaleCompare(keyword,"mattecolor") == 0)
         {
           (void) QueryColorDatabase(value,&image_info->matte_color,
@@ -7757,12 +7979,26 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
     {
       if (LocaleCompare(keyword,"pointsize") == 0)
         {
-          draw_info->pointsize=atof(value);
+          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':
     {
@@ -7774,6 +8010,7 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
       if (LocaleCompare(keyword,"stroke") == 0)
         {
           (void) QueryColorDatabase(value,&draw_info->stroke,exception);
+          (void) SetImageOption(image_info,keyword,value);
           break;
         }
       ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword);
@@ -7787,6 +8024,7 @@ static MagickBooleanType SetMSLAttributes(MSLInfo *msl_info,const char *keyword,
   }
   return(MagickTrue);
 }
+#endif
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%