]> granicus.if.org Git - imagemagick/blobdiff - PerlMagick/Magick.xs
(no commit message)
[imagemagick] / PerlMagick / Magick.xs
index 5bd21cbc517a652ed106262b94841a60255a2cf2..2dc94d6a1ce3263471a940188c3541d10de7bdf8 100644 (file)
 /*
   Include declarations.
 */
-#if !defined(WIN32)
-#define MagickExport
-#endif
-
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
@@ -61,7 +57,7 @@ extern "C" {
 #include "perl.h"
 #include "XSUB.h"
 #include <math.h>
-#include <magick/MagickCore.h>
+#include <MagickCore/MagickCore.h>
 #undef tainted
 
 #if defined(__cplusplus) || defined(c_plusplus)
@@ -78,7 +74,6 @@ extern "C" {
 #endif
 #define DegreesToRadians(x)  (MagickPI*(x)/180.0)
 #define EndOf(array)  (&array[NumberOf(array)])
-#define MagickPI  3.14159265358979323846264338327950288419716939937510
 #define MaxArguments  33
 #ifndef na
 #define na  PL_na
@@ -121,7 +116,7 @@ extern "C" {
  \
   if ((exception)->severity != UndefinedException) \
     { \
-      (void) FormatMagickString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
+      (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
         (exception)->severity, (exception)->reason ? \
         GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
         "Unknown", (exception)->description ? " (" : "", \
@@ -211,15 +206,16 @@ static struct
   {
     { "Comment", { {"comment", StringReference} } },
     { "Label", { {"label", StringReference} } },
-    { "AddNoise", { {"noise", MagickNoiseOptions},
+    { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
       {"channel", MagickChannelOptions} } },
-    { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
+    { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
     { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"fill", StringReference},
       {"bordercolor", StringReference}, {"color", StringReference},
       {"compose", MagickComposeOptions} } },
     { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
-      {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
+      {"sigma", RealReference}, {"bias", RealReference},
+      {"channel", MagickChannelOptions} } },
     { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"x", IntegerReference},
       {"y", IntegerReference} } },
@@ -242,10 +238,10 @@ static struct
       {"interpolate", MagickInterpolateOptions} } },
     { "Magnify", },
     { "MedianFilter", { {"geometry", StringReference},
-      {"width", IntegerReference},{"height", IntegerReference},
+      {"width", IntegerReference}, {"height", IntegerReference},
       {"channel", MagickChannelOptions} } },
     { "Minify", },
-    { "OilPaint", { {"radius", RealReference} } },
+    { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
     { "ReduceNoise", { {"geometry", StringReference},
       {"width", IntegerReference},{"height", IntegerReference},
       {"channel", MagickChannelOptions} } },
@@ -260,11 +256,13 @@ static struct
     { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
       {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
     { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
-      {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
+      {"sigma", RealReference}, {"bias", RealReference},
+      {"channel", MagickChannelOptions} } },
     { "Shear", { {"geometry", StringReference}, {"x", RealReference},
       {"y", RealReference}, { "fill", StringReference},
       {"color", StringReference} } },
-    { "Spread", { {"radius", RealReference} } },
+    { "Spread", { {"radius", RealReference},
+      {"interpolate", MagickInterpolateOptions} } },
     { "Swirl", { {"degrees", RealReference},
       {"interpolate", MagickInterpolateOptions} } },
     { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
@@ -372,7 +370,7 @@ static struct
     { "Threshold", { {"threshold", StringReference},
       {"channel", MagickChannelOptions} } },
     { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
-      {"sigma", RealReference} } },
+      {"sigma", RealReference}, {"biabias", RealReference} } },
     { "Trim", { {"fuzz", StringReference} } },
     { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
       {"wavelength", RealReference},
@@ -385,9 +383,10 @@ static struct
     { "Deconstruct", },
     { "GaussianBlur", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"channel", MagickChannelOptions} } },
+      {"bias", RealReference}, {"channel", MagickChannelOptions} } },
     { "Convolve", { {"coefficients", ArrayReference},
-      {"channel", MagickChannelOptions}, {"bias", StringReference} } },
+      {"channel", MagickChannelOptions}, {"bias", StringReference},
+      {"kernel", StringReference} } },
     { "Profile", { {"name", StringReference}, {"profile", StringReference},
       { "rendering-intent", MagickIntentOptions},
       { "black-point-compensation", MagickBooleanOptions} } },
@@ -397,7 +396,8 @@ static struct
       {"channel", MagickChannelOptions} } },
     { "MotionBlur", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"angle", RealReference}, {"channel", MagickChannelOptions} } },
+      {"angle", RealReference}, {"bias", RealReference},
+      {"channel", MagickChannelOptions} } },
     { "OrderedDither", { {"threshold", StringReference},
       {"channel", MagickChannelOptions} } },
     { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
@@ -414,7 +414,7 @@ static struct
     { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
     { "AdaptiveThreshold", { {"geometry", StringReference},
       {"width", IntegerReference}, {"height", IntegerReference},
-      {"offset", IntegerReference} } },
+      {"bias", RealReference} } },
     { "Resample", { {"density", StringReference}, {"x", RealReference},
       {"y", RealReference}, {"filter", MagickFilterOptions},
       {"support", RealReference }, {"blur", RealReference } } },
@@ -424,11 +424,11 @@ static struct
     { "WhiteThreshold", { {"threshold", StringReference},
       {"channel", MagickChannelOptions} } },
     { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
-      {"channel", MagickChannelOptions} } },
+      {"bias", RealReference}, {"channel", MagickChannelOptions} } },
     { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference} } },
     { "Strip", },
-    { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
+    { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
     { "Channel", { {"channel", MagickChannelOptions} } },
     { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"x", IntegerReference},
@@ -459,31 +459,32 @@ static struct
     { "Sans1", },
     { "AdaptiveSharpen", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"channel", MagickChannelOptions} } },
+      {"bias", RealReference}, {"channel", MagickChannelOptions} } },
     { "Transpose", },
     { "Transverse", },
     { "AutoOrient", },
     { "AdaptiveBlur", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"channel", MagickChannelOptions} } },
+      {"bias", RealReference}, {"channel", MagickChannelOptions} } },
     { "Sketch", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"angle", RealReference} } },
+      {"angle", RealReference}, {"bias", RealReference} } },
     { "UniqueColors", },
     { "AdaptiveResize", { {"geometry", StringReference},
       {"width", IntegerReference}, {"height", IntegerReference},
       {"filter", MagickFilterOptions}, {"support", StringReference },
-      {"blur", RealReference } } },
+      {"blur", RealReference }, {"interpolate", MagickInterpolateOptions} } },
     { "ClipMask", { {"mask", ImageReference} } },
     { "LinearStretch", { {"levels", StringReference},
       {"black-point", RealReference},{"white-point", RealReference} } },
-    { "Recolor", { {"matrix", ArrayReference} } },
+    { "ColorMatrix", { {"matrix", ArrayReference} } },
     { "Mask", { {"mask", ImageReference} } },
     { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
       {"font", StringReference}, {"stroke", StringReference},
       {"fill", StringReference}, {"strokewidth", RealReference},
       {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
-      {"background", StringReference} } },
+      {"background", StringReference},
+      {"interpolate", MagickInterpolateOptions} } },
     { "FloodfillPaint", { {"geometry", StringReference},
       {"x", IntegerReference}, {"y", IntegerReference},
       {"fill", StringReference}, {"bordercolor", StringReference},
@@ -493,6 +494,7 @@ static struct
       {"virtual-pixel", MagickVirtualPixelOptions},
       {"best-fit", MagickBooleanOptions} } },
     { "Clut", { {"image", ImageReference},
+      {"interpolate", MagickInterpolateOptions},
       {"channel", MagickChannelOptions} } },
     { "LiquidRescale", { {"geometry", StringReference},
       {"width", IntegerReference}, {"height", IntegerReference},
@@ -512,7 +514,8 @@ static struct
       {"virtual-pixel", MagickVirtualPixelOptions} } },
     { "SelectiveBlur", { {"geometry", StringReference},
       {"radius", RealReference}, {"sigma", RealReference},
-      {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
+      {"threshold", RealReference}, {"bias", RealReference},
+      {"channel", MagickChannelOptions} } },
     { "HaldClut", { {"image", ImageReference},
       {"channel", MagickChannelOptions} } },
     { "BlueShift", { {"factor", StringReference} } },
@@ -526,15 +529,13 @@ static struct
       {"black-point", StringReference}, {"white-point", StringReference},
       {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
     { "Clamp", { {"channel", MagickChannelOptions} } },
-    { "Filter", { {"kernel", StringReference},
-      {"channel", MagickChannelOptions}, {"bias", StringReference} } },
     { "BrightnessContrast", { {"levels", StringReference},
       {"brightness", RealReference},{"contrast", RealReference},
       {"channel", MagickChannelOptions} } },
     { "Morphology", { {"kernel", StringReference},
       {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
       {"iterations", IntegerReference} } },
-    { "ColorMatrix", { {"matrix", ArrayReference} } },
+    { "Sans", { {"matrix", ArrayReference} } },
     { "Color", { {"color", StringReference} } },
     { "Mode", { {"geometry", StringReference},
       {"width", IntegerReference},{"height", IntegerReference},
@@ -722,7 +723,7 @@ static double constant(char *name,ssize_t sans)
     case 'O':
     {
       if (strEQ(name,"Opaque"))
-        return(OpaqueOpacity);
+        return(OpaqueAlpha);
       if (strEQ(name,"OptionError"))
         return(OptionError);
       if (strEQ(name,"OptionWarning"))
@@ -734,7 +735,7 @@ static double constant(char *name,ssize_t sans)
       if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
         return(MAGICKCORE_QUANTUM_DEPTH);
       if (strEQ(name,"QuantumDepth"))
-        return(QuantumDepth);
+        return(MAGICKCORE_QUANTUM_DEPTH);
       if (strEQ(name,"QuantumRange"))
         return(QuantumRange);
       break;
@@ -764,7 +765,7 @@ static double constant(char *name,ssize_t sans)
     case 'T':
     {
       if (strEQ(name,"Transparent"))
-        return(TransparentOpacity);
+        return(TransparentAlpha);
       if (strEQ(name,"TypeError"))
         return(TypeError);
       if (strEQ(name,"TypeWarning"))
@@ -843,8 +844,8 @@ static void DestroyPackageInfo(struct PackageInfo *info)
 %    o info: a structure of type info.
 %
 */
-static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,ssize_t *current,
-  ssize_t *last,ExceptionInfo *exception)
+static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
+  ssize_t *current,ssize_t *last,ExceptionInfo *exception)
 {
   Image
     *image;
@@ -980,7 +981,7 @@ static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
   SV
     *sv;
 
-  (void) FormatMagickString(message,MaxTextExtent,"%s::package%s%p",
+  (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
     PackageName,XS_VERSION,reference);
   sv=perl_get_sv(message,(TRUE | 0x02));
   if (sv == (SV *) NULL)
@@ -1025,32 +1026,37 @@ static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
 %
 */
 
-static double SiPrefixToDouble(const char *string,const double interval)
+static double SiPrefixToDoubleInterval(const char *string,const double interval)
 {
   char
     *q;
 
   double
-    scale,
     value;
 
-  value=StringToDouble(string,&q);
-  scale=1000.0;
-  if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
-    scale=1024.0;
-  switch (tolower((int) ((unsigned char) *q)))
-  {
-    case '%': value*=pow(scale,0)*interval/100.0; break;
-    case 'k': value*=pow(scale,1); break;
-    case 'm': value*=pow(scale,2); break;
-    case 'g': value*=pow(scale,3); break;
-    case 't': value*=pow(scale,4); break;
-    case 'p': value*=pow(scale,5); break;
-    case 'e': value*=pow(scale,6); break;
-    case 'z': value*=pow(scale,7); break;
-    case 'y': value*=pow(scale,8); break;
-    default:  break;
-  }
+  value=InterpretSiPrefixValue(string,&q);
+  if (*q == '%')
+    value*=interval/100.0;
+  return(value);
+}
+
+static inline double StringToDouble(const char *restrict string,
+  char **restrict sentinal)
+{
+  return(InterpretLocaleValue(string,sentinal));
+}
+
+static double StringToDoubleInterval(const char *string,const double interval)
+{
+  char
+    *q;
+
+  double
+    value;
+
+  value=InterpretLocaleValue(string,&q);
+  if (*q == '%')
+    value*=interval/100.0;
   return(value);
 }
 
@@ -1069,13 +1075,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
     x,
     y;
 
-  MagickPixelPacket
+  PixelInfo
     pixel;
 
   MagickStatusType
     flags;
 
-  PixelPacket
+  PixelInfo
     *color,
     target_color;
 
@@ -1112,7 +1118,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
               break;
             }
           for ( ; image; image=image->next)
-            (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
+            (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
           break;
         }
       if (LocaleCompare(attribute,"antialias") == 0)
@@ -1136,7 +1142,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(AreaResource,limit);
           break;
         }
@@ -1149,13 +1156,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (LocaleCompare(attribute,"authenticate") == 0)
         {
           if (info)
-            (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
+            SetImageOption(info->image_info,attribute,SvPV(sval,na));
           break;
         }
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'B':
@@ -1163,7 +1170,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
     {
       if (LocaleCompare(attribute,"background") == 0)
         {
-          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
+          (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
+            exception);
           if (info)
             info->image_info->background_color=target_color;
           for ( ; image; image=image->next)
@@ -1173,7 +1181,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (LocaleCompare(attribute,"bias") == 0)
         {
           for ( ; image; image=image->next)
-            image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
+            image->bias=StringToDoubleInterval(SvPV(sval,na),(double)
+              QuantumRange+1.0);
           break;
         }
       if (LocaleCompare(attribute,"blue-primary") == 0)
@@ -1191,7 +1200,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
         }
       if (LocaleCompare(attribute,"bordercolor") == 0)
         {
-          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
+          (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
+            exception);
           if (info)
             info->image_info->border_color=target_color;
           for ( ; image; image=image->next)
@@ -1201,7 +1211,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'C':
@@ -1210,9 +1220,9 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (LocaleCompare(attribute,"cache-threshold") == 0)
         {
           (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
-            SiPrefixToDouble(SvPV(sval,na),100.0));
+            SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
           (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
-            (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
+            (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
           break;
         }
       if (LocaleCompare(attribute,"clip-mask") == 0)
@@ -1224,7 +1234,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           if (SvPOK(sval))
             clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
           for ( ; image; image=image->next)
-            SetImageClipMask(image,clip_mask);
+            SetImageClipMask(image,clip_mask,exception);
           break;
         }
       if (LocaleNCompare(attribute,"colormap",8) == 0)
@@ -1241,11 +1251,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
               continue;
             i=0;
             items=sscanf(attribute,"%*[^[][%ld",&i);
+            (void) items;
             if (i > (ssize_t) image->colors)
               i%=image->colors;
             if ((strchr(SvPV(sval,na),',') == 0) ||
                 (strchr(SvPV(sval,na),')') != 0))
-              QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
+              QueryColorCompliance(SvPV(sval,na),AllCompliance,
+                image->colormap+i,exception);
             else
               {
                 color=image->colormap+i;
@@ -1274,7 +1286,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
               break;
             }
           for ( ; image; image=image->next)
-            (void) TransformImageColorspace(image,(ColorspaceType) sp);
+            (void) TransformImageColorspace(image,(ColorspaceType) sp,
+              exception);
           break;
         }
       if (LocaleCompare(attribute,"comment") == 0)
@@ -1282,7 +1295,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           for ( ; image; image=image->next)
             (void) SetImageProperty(image,"Comment",InterpretImageProperties(
               info ? info->image_info : (ImageInfo *) NULL,image,
-              SvPV(sval,na)));
+              SvPV(sval,na),exception),exception);
           break;
         }
       if (LocaleCompare(attribute,"compression") == 0)
@@ -1304,7 +1317,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'D':
@@ -1334,7 +1347,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(DiskResource,limit);
           break;
         }
@@ -1351,10 +1365,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           for ( ; image; image=image->next)
           {
             flags=ParseGeometry(SvPV(sval,na),&geometry_info);
-            image->x_resolution=geometry_info.rho;
-            image->y_resolution=geometry_info.sigma;
+            image->resolution.x=geometry_info.rho;
+            image->resolution.y=geometry_info.sigma;
             if ((flags & SigmaValue) == 0)
-              image->y_resolution=image->x_resolution;
+              image->resolution.y=image->resolution.x;
           }
           break;
         }
@@ -1363,7 +1377,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           if (info)
             info->image_info->depth=SvIV(sval);
           for ( ; image; image=image->next)
-            (void) SetImageDepth(image,SvIV(sval));
+            (void) SetImageDepth(image,SvIV(sval),exception);
           break;
         }
       if (LocaleCompare(attribute,"dispose") == 0)
@@ -1406,7 +1420,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'E':
@@ -1439,7 +1453,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'F':
@@ -1499,15 +1513,17 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (LocaleCompare(attribute,"fuzz") == 0)
         {
           if (info)
-            info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
+            info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
+              QuantumRange+1.0);
           for ( ; image; image=image->next)
-            image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
+            image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
+              QuantumRange+1.0);
           break;
         }
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'G':
@@ -1551,7 +1567,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'I':
@@ -1559,17 +1575,14 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
     {
       if (LocaleNCompare(attribute,"index",5) == 0)
         {
-          IndexPacket
-            *indexes;
-
           int
             items;
 
           long
             index;
 
-          register PixelPacket
-            *p;
+          register Quantum
+            *q;
 
           CacheView
             *image_view;
@@ -1581,14 +1594,14 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
             x=0;
             y=0;
             items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
+            (void) items;
             image_view=AcquireCacheView(image);
-            p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
-            if (p != (PixelPacket *) NULL)
+            q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
+            if (q != (Quantum *) NULL)
               {
-                indexes=GetCacheViewAuthenticIndexQueue(image_view);
                 items=sscanf(SvPV(sval,na),"%ld",&index);
                 if ((index >= 0) && (index < (ssize_t) image->colors))
-                  SetIndexPixelComponent(indexes,index);
+                  SetPixelIndex(image,index,q);
                 (void) SyncCacheViewAuthenticPixels(image_view,exception);
               }
             image_view=DestroyCacheView(image_view);
@@ -1621,7 +1634,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'L':
@@ -1632,7 +1645,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           for ( ; image; image=image->next)
             (void) SetImageProperty(image,"label",InterpretImageProperties(
               info ? info->image_info : (ImageInfo *) NULL,image,
-              SvPV(sval,na)));
+              SvPV(sval,na),exception),exception);
           break;
         }
       if (LocaleCompare(attribute,"loop") == 0)
@@ -1640,7 +1653,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'M':
@@ -1649,7 +1662,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (LocaleCompare(attribute,"magick") == 0)
         {
           if (info)
-            (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
+            (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
               "%s:",SvPV(sval,na));
           for ( ; image; image=image->next)
             (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
@@ -1662,7 +1675,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(MapResource,limit);
           break;
         }
@@ -1675,12 +1689,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           if (SvPOK(sval))
             mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
           for ( ; image; image=image->next)
-            SetImageMask(image,mask);
+            SetImageMask(image,mask,exception);
           break;
         }
       if (LocaleCompare(attribute,"mattecolor") == 0)
         {
-          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
+          (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
+            exception);
           if (info)
             info->image_info->matte_color=target_color;
           for ( ; image; image=image->next)
@@ -1708,7 +1723,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(MemoryResource,limit);
           break;
         }
@@ -1725,13 +1741,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           if (info)
             info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
           for ( ; image; image=image->next)
-            (void) SetImageType(image,BilevelType);
+            (void) SetImageType(image,BilevelType,exception);
           break;
         }
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'O':
@@ -1762,7 +1778,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'P':
@@ -1792,13 +1808,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           int
             items;
 
-          MagickPixelPacket
+          PixelInfo
             pixel;
 
-          register IndexPacket
-            *indexes;
-
-          register PixelPacket
+          register Quantum
             *q;
 
           CacheView
@@ -1806,22 +1819,23 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           for ( ; image; image=image->next)
           {
-            if (SetImageStorageClass(image,DirectClass) == MagickFalse)
+            if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
               break;
             x=0;
             y=0;
             items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
+            (void) items;
             image_view=AcquireCacheView(image);
             q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
-            indexes=GetCacheViewAuthenticIndexQueue(image_view);
-            if (q != (PixelPacket *) NULL)
+            if (q != (Quantum *) NULL)
               {
                 if ((strchr(SvPV(sval,na),',') == 0) ||
                     (strchr(SvPV(sval,na),')') != 0))
-                  QueryMagickColor(SvPV(sval,na),&pixel,exception);
+                  QueryColorCompliance(SvPV(sval,na),AllCompliance,
+                    &pixel,exception);
                 else
                   {
-                    GetMagickPixelPacket(image,&pixel);
+                    GetPixelInfo(image,&pixel);
                     flags=ParseGeometry(SvPV(sval,na),&geometry_info);
                     pixel.red=geometry_info.rho;
                     if ((flags & SigmaValue) != 0)
@@ -1829,18 +1843,16 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
                     if ((flags & XiValue) != 0)
                       pixel.blue=geometry_info.xi;
                     if ((flags & PsiValue) != 0)
-                      pixel.opacity=geometry_info.psi;
+                      pixel.alpha=geometry_info.psi;
                     if ((flags & ChiValue) != 0)
-                      pixel.index=geometry_info.chi;
+                      pixel.black=geometry_info.chi;
                   }
-                SetRedPixelComponent(q,ClampToQuantum(pixel.red));
-                SetGreenPixelComponent(q,ClampToQuantum(pixel.green));
-                SetBluePixelComponent(q,ClampToQuantum(pixel.blue));
-                SetOpacityPixelComponent(q,ClampToQuantum(pixel.opacity));
-                if (((image->colorspace == CMYKColorspace) ||
-                     (image->storage_class == PseudoClass)) &&
-                    (indexes != (IndexPacket *) NULL))
-                  SetIndexPixelComponent(indexes,ClampToQuantum(pixel.index));
+                SetPixelRed(image,ClampToQuantum(pixel.red),q);
+                SetPixelGreen(image,ClampToQuantum(pixel.green),q);
+                SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
+                if (image->colorspace == CMYKColorspace)
+                  SetPixelBlack(image,ClampToQuantum(pixel.black),q);
+                SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
                 (void) SyncCacheViewAuthenticPixels(image_view,exception);
               }
             image_view=DestroyCacheView(image_view);
@@ -1873,7 +1885,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'Q':
@@ -1890,7 +1902,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'R':
@@ -1966,7 +1978,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'S':
@@ -1991,18 +2003,6 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
             image->scene=SvIV(sval);
           break;
         }
-      if (LocaleCompare(attribute,"subimage") == 0)
-        {
-          if (info)
-            info->image_info->subimage=SvIV(sval);
-          break;
-        }
-      if (LocaleCompare(attribute,"subrange") == 0)
-        {
-          if (info)
-            info->image_info->subrange=SvIV(sval);
-          break;
-        }
       if (LocaleCompare(attribute,"server") == 0)
         goto display;
       if (LocaleCompare(attribute,"size") == 0)
@@ -2028,7 +2028,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'T':
@@ -2047,16 +2047,11 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(ThreadResource,limit);
           break;
         }
-      if (LocaleCompare(attribute,"tile") == 0)
-        {
-          if (info)
-            (void) CloneString(&info->image_info->tile,SvPV(sval,na));
-          break;
-        }
       if (LocaleCompare(attribute,"tile-offset") == 0)
         {
           char
@@ -2078,13 +2073,15 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
 
           limit=MagickResourceInfinity;
           if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
-            limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
+            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
+              100.0);
           (void) SetMagickResourceLimit(TimeResource,limit);
           break;
         }
       if (LocaleCompare(attribute,"transparent-color") == 0)
         {
-          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
+          (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
+            exception);
           if (info)
             info->image_info->transparent_color=target_color;
           for ( ; image; image=image->next)
@@ -2104,13 +2101,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
           if (info)
             info->image_info->type=(ImageType) sp;
           for ( ; image; image=image->next)
-            SetImageType(image,(ImageType) sp);
+            SetImageType(image,(ImageType) sp,exception);
           break;
         }
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'U':
@@ -2142,8 +2139,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
                 {
                   if (units == PixelsPerCentimeterResolution)
                     {
-                      image->x_resolution*=2.54;
-                      image->y_resolution*=2.54;
+                      image->resolution.x*=2.54;
+                      image->resolution.y*=2.54;
                     }
                   break;
                 }
@@ -2151,8 +2148,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
                 {
                   if (units == PixelsPerInchResolution)
                     {
-                      image->x_resolution/=2.54;
-                      image->y_resolution/=2.54;
+                      image->resolution.x/=2.54;
+                      image->resolution.y/=2.54;
                     }
                   break;
                 }
@@ -2164,7 +2161,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'V':
@@ -2209,7 +2206,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     case 'W':
@@ -2231,7 +2228,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
     default:
@@ -2239,7 +2236,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
       if (info)
         SetImageOption(info->image_info,attribute,SvPV(sval,na));
       for ( ; image; image=image->next)
-        SetImageProperty(image,attribute,SvPV(sval,na));
+        SetImageProperty(image,attribute,SvPV(sval,na),exception);
       break;
     }
   }
@@ -2449,9 +2446,8 @@ Animate(ref,...)
         for (i=2; i < items; i+=2)
           SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
             exception);
-    (void) AnimateImages(package_info->image_info,image);
+    (void) AnimateImages(package_info->image_info,image,exception);
     (void) CatchImageException(image);
-    InheritException(exception,&image->exception);
 
   PerlException:
     if (package_info != (struct PackageInfo *) NULL)
@@ -2681,7 +2677,7 @@ Average(ref)
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
     info=GetPackageInfo(aTHX_ (void *) av,info,exception);
-    (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
+    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
       "average-%.*s",(int) (MaxTextExtent-9),
       ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
     (void) CopyMagickString(image->filename,info->image_info->filename,
@@ -3091,7 +3087,7 @@ void
 Compare(ref,...)
   Image::Magick ref=NO_INIT
   ALIAS:
-    CompareImage = 1
+    CompareImages = 1
     compare      = 2
     compareimage = 3
   PPCODE:
@@ -3102,9 +3098,6 @@ Compare(ref,...)
     char
       *attribute;
 
-    ChannelType
-      channel;
-
     double
       distortion;
 
@@ -3167,7 +3160,6 @@ Compare(ref,...)
     /*
       Get attribute.
     */
-    channel=DefaultChannels;
     reconstruct_image=image;
     metric=RootMeanSquaredErrorMetric;
     for (i=2; i < items; i+=2)
@@ -3190,7 +3182,7 @@ Compare(ref,...)
                     "UnrecognizedType",SvPV(ST(i),na));
                   return;
                 }
-              channel=(ChannelType) option;
+              SetPixelChannelMapMask(image,(ChannelType) option);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -3202,7 +3194,7 @@ Compare(ref,...)
         {
           if (LocaleCompare(attribute,"fuzz") == 0)
             {
-              image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
+              image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -3250,8 +3242,8 @@ Compare(ref,...)
         }
       }
     }
-    difference_image=CompareImageChannels(image,reconstruct_image,channel,
-      metric,&distortion,exception);
+    difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
+      exception);
     if (difference_image != (Image *) NULL)
       {
         difference_image->error.mean_error_per_pixel=distortion;
@@ -3290,7 +3282,7 @@ void
 CompareLayers(ref)
   Image::Magick ref=NO_INIT
   ALIAS:
-    CompareImageLayers   = 1
+    CompareImagesLayers   = 1
     comparelayers        = 2
     compareimagelayers   = 3
   PPCODE:
@@ -3386,7 +3378,7 @@ CompareLayers(ref)
         }
       }
     }
-    image=CompareImageLayers(image,method,exception);
+    image=CompareImagesLayers(image,method,exception);
     if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
       goto PerlException;
     for ( ; image; image=image->next)
@@ -3459,7 +3451,7 @@ DESTROY(ref)
         /*
           Array (AV *) reference
         */
-        (void) FormatMagickString(message,MaxTextExtent,"package%s%p",
+        (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
           XS_VERSION,reference);
         hv=gv_stashpv(PackageName, FALSE);
         if (!hv)
@@ -3474,6 +3466,7 @@ DESTROY(ref)
             DestroyPackageInfo(info);
           }
         key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
+        (void) key;
         break;
       }
       case SVt_PVMG:
@@ -3559,9 +3552,8 @@ Display(ref,...)
         for (i=2; i < items; i+=2)
           SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
             exception);
-    (void) DisplayImages(package_info->image_info,image);
+    (void) DisplayImages(package_info->image_info,image,exception);
     (void) CatchImageException(image);
-    InheritException(exception,&image->exception);
 
   PerlException:
     if (package_info != (struct PackageInfo *) NULL)
@@ -3712,7 +3704,7 @@ EvaluateImages(ref)
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
     info=GetPackageInfo(aTHX_ (void *) av,info,exception);
-    (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
+    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
       "evaluate-%.*s",(int) (MaxTextExtent-9),
       ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
     (void) CopyMagickString(image->filename,info->image_info->filename,
@@ -3754,46 +3746,46 @@ Features(ref,...)
   {
 #define ChannelFeatures(channel,direction) \
 { \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].angular_second_moment[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].contrast[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].contrast[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].variance_sum_of_squares[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].inverse_difference_moment[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].sum_average[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].sum_variance[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].sum_entropy[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].entropy[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].difference_variance[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].difference_entropy[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].measure_of_correlation_1[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].measure_of_correlation_2[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_features[channel].maximum_correlation_coefficient[direction]); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
 }
@@ -3814,9 +3806,6 @@ Features(ref,...)
     ExceptionInfo
       *exception;
 
-    HV
-      *hv;
-
     Image
       *image;
 
@@ -3830,7 +3819,6 @@ Features(ref,...)
       *info;
 
     SV
-      *av_reference,
       *perl_exception,
       *reference;
 
@@ -3846,9 +3834,7 @@ Features(ref,...)
         goto PerlException;
       }
     reference=SvRV(ST(0));
-    hv=SvSTASH(reference);
     av=newAV();
-    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
     image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
     if (image == (Image *) NULL)
@@ -3887,8 +3873,7 @@ Features(ref,...)
     count=0;
     for ( ; image; image=image->next)
     {
-      channel_features=GetImageChannelFeatures(image,distance,
-        &image->exception);
+      channel_features=GetImageFeatures(image,distance,exception);
       if (channel_features == (ChannelFeatures *) NULL)
         continue;
       count++;
@@ -3899,9 +3884,9 @@ Features(ref,...)
         ChannelFeatures(GreenChannel,i);
         ChannelFeatures(BlueChannel,i);
         if (image->colorspace == CMYKColorspace)
-          ChannelFeatures(IndexChannel,i);
+          ChannelFeatures(BlackChannel,i);
         if (image->matte != MagickFalse)
-          ChannelFeatures(OpacityChannel,i);
+          ChannelFeatures(AlphaChannel,i);
       }
       channel_features=(ChannelFeatures *)
         RelinquishMagickMemory(channel_features);
@@ -3950,7 +3935,7 @@ Flatten(ref)
     Image
       *image;
 
-    PixelPacket
+    PixelInfo
       background_color;
 
     register ssize_t
@@ -3987,8 +3972,8 @@ Flatten(ref)
       }
     background_color=image->background_color;
     if (items == 2)
-      (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
-        exception);
+      (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
+        &background_color,exception);
     else
       for (i=2; i < items; i+=2)
       {
@@ -4000,8 +3985,8 @@ Flatten(ref)
           {
             if (LocaleCompare(attribute,"background") == 0)
               {
-                (void) QueryColorDatabase((char *) SvPV(ST(1),na),
-                  &background_color,exception);
+                (void) QueryColorCompliance((char *) SvPV(ST(1),na),
+                  AllCompliance,&background_color,exception);
                 break;
               }
             ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -4031,7 +4016,7 @@ Flatten(ref)
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
     info=GetPackageInfo(aTHX_ (void *) av,info,exception);
-    (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
+    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
       "flatten-%.*s",(int) (MaxTextExtent-9),
       ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
     (void) CopyMagickString(image->filename,info->image_info->filename,
@@ -4079,7 +4064,8 @@ Fx(ref,...)
       expression[MaxTextExtent];
 
     ChannelType
-      channel;
+      channel,
+      channel_mask;
 
     ExceptionInfo
       *exception;
@@ -4185,7 +4171,10 @@ Fx(ref,...)
           }
         }
       }
-    image=FxImageChannel(image,channel,expression,exception);
+    channel_mask=SetPixelChannelMask(image,channel);
+    image=FxImage(image,expression,exception);
+    if (image != (Image *) NULL)
+      (void) SetPixelChannelMask(image,channel_mask);
     if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
       goto PerlException;
     for ( ; image; image=image->next)
@@ -4308,7 +4297,7 @@ Get(ref,...)
               const char
                 *value;
 
-              value=GetImageProperty(image,attribute);
+              value=GetImageProperty(image,attribute,exception);
               if (value != (const char *) NULL)
                 s=newSVpv(value,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -4317,7 +4306,14 @@ Get(ref,...)
           if (LocaleCompare(attribute,"authenticate") == 0)
             {
               if (info)
-                s=newSVpv(info->image_info->authenticate,0);
+                {
+                  const char
+                    *option;
+
+                  option=GetImageOption(info->image_info,attribute);
+                  if (option != (const char *) NULL)
+                    s=newSVpv(option,0);
+                }
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4332,10 +4328,10 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
-                QuantumFormat "," QuantumFormat "," QuantumFormat,
-                image->background_color.red,image->background_color.green,
-                image->background_color.blue,image->background_color.opacity);
+              (void) FormatLocaleString(color,MaxTextExtent,
+                "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
+                image->background_color.green,image->background_color.blue,
+                image->background_color.alpha);
               s=newSVpv(color,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4386,7 +4382,7 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
+              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
                 image->chromaticity.blue_primary.x,
                 image->chromaticity.blue_primary.y);
               s=newSVpv(color,0);
@@ -4397,10 +4393,10 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
-                QuantumFormat "," QuantumFormat "," QuantumFormat,
-                image->border_color.red,image->border_color.green,
-                image->border_color.blue,image->border_color.opacity);
+              (void) FormatLocaleString(color,MaxTextExtent,
+                "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
+                image->border_color.green,image->border_color.blue,
+                image->border_color.alpha);
               s=newSVpv(color,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4415,8 +4411,8 @@ Get(ref,...)
 
               if (image == (Image *) NULL)
                 break;
-              page=GetImageBoundingBox(image,&image->exception);
-              (void) FormatMagickString(geometry,MaxTextExtent,
+              page=GetImageBoundingBox(image,exception);
+              (void) FormatLocaleString(geometry,MaxTextExtent,
                 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
                 page.height,(double) page.x,(double) page.y);
               s=newSVpv(geometry,0);
@@ -4450,7 +4446,7 @@ Get(ref,...)
 
                   sv=NULL;
                   if (image->mask == (Image *) NULL)
-                    ClipImage(image);
+                    ClipImage(image,exception);
                   if (image->mask != (Image *) NULL)
                     {
                       AddImageToRegistry(sv,image->mask);
@@ -4469,7 +4465,7 @@ Get(ref,...)
 
                   sv=NULL;
                   if (image->clip_mask == (Image *) NULL)
-                    ClipImage(image);
+                    ClipImage(image,exception);
                   if (image->clip_mask != (Image *) NULL)
                     {
                       AddImageToRegistry(sv,image->clip_mask);
@@ -4507,7 +4503,7 @@ Get(ref,...)
             {
               if (image != (Image *) NULL)
                 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
-                  &image->exception));
+                  exception));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4520,12 +4516,13 @@ Get(ref,...)
                 break;
               j=0;
               items=sscanf(attribute,"%*[^[][%ld",&j);
+              (void) items;
               if (j > (ssize_t) image->colors)
                 j%=image->colors;
-              (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
-                QuantumFormat "," QuantumFormat "," QuantumFormat,
-                image->colormap[j].red,image->colormap[j].green,
-                image->colormap[j].blue,image->colormap[j].opacity);
+              (void) FormatLocaleString(color,MaxTextExtent,
+                "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
+                image->colormap[j].green,image->colormap[j].blue,
+                image->colormap[j].alpha);
               s=newSVpv(color,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4542,7 +4539,7 @@ Get(ref,...)
               const char
                 *value;
 
-              value=GetImageProperty(image,attribute);
+              value=GetImageProperty(image,attribute,exception);
               if (value != (const char *) NULL)
                 s=newSVpv(value,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -4568,8 +4565,8 @@ Get(ref,...)
 
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(geometry,MaxTextExtent,"%.15gx%.15g",
-                image->x_resolution,image->y_resolution);
+              (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
+                image->resolution.x,image->resolution.y);
               s=newSVpv(geometry,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4585,7 +4582,7 @@ Get(ref,...)
             {
               s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
               if (image != (Image *) NULL)
-                s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
+                s=newSViv((ssize_t) GetImageDepth(image,exception));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4710,7 +4707,7 @@ Get(ref,...)
               if (info && (*info->image_info->magick != '\0'))
                 magick_info=GetMagickInfo(info->image_info->magick,exception);
               if (image != (Image *) NULL)
-                magick_info=GetMagickInfo(image->magick,&image->exception);
+                magick_info=GetMagickInfo(image->magick,exception);
               if ((magick_info != (const MagickInfo *) NULL) &&
                   (*magick_info->description != '\0'))
                 s=newSVpv((char *) magick_info->description,0);
@@ -4760,7 +4757,7 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
+              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
                 image->chromaticity.green_primary.x,
                 image->chromaticity.green_primary.y);
               s=newSVpv(color,0);
@@ -4831,10 +4828,11 @@ Get(ref,...)
                   static ssize_t
                     id = 0;
 
-                  (void) FormatMagickString(key,MaxTextExtent,"%.20g\n",(double)
+                  (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
                     id);
                   status=SetImageRegistry(ImageRegistryType,key,image,
-                    &image->exception);
+                    exception);
+                  (void) status;
                   s=newSViv(id++);
                 }
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -4852,10 +4850,7 @@ Get(ref,...)
                 x,
                 y;
 
-              register const IndexPacket
-                *indexes;
-
-              register const PixelPacket
+              register const Quantum
                 *p;
 
               CacheView
@@ -4868,13 +4863,13 @@ Get(ref,...)
               x=0;
               y=0;
               items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
+              (void) items;
               image_view=AcquireCacheView(image);
-              p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
-              if (p != (const PixelPacket *) NULL)
+              p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
+              if (p != (const Quantum *) NULL)
                 {
-                  indexes=GetCacheViewVirtualIndexQueue(image_view);
-                  (void) FormatMagickString(name,MaxTextExtent,QuantumFormat,
-                    GetIndexPixelComponent(indexes));
+                  (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
+                    GetPixelIndex(image,p));
                   s=newSVpv(name,0);
                   PUSHs(s ? sv_2mortal(s) : &sv_undef);
                 }
@@ -4928,7 +4923,7 @@ Get(ref,...)
 
               if (image == (Image *) NULL)
                 break;
-              value=GetImageProperty(image,"Label");
+              value=GetImageProperty(image,"Label",exception);
               if (value != (const char *) NULL)
                 s=newSVpv(value,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -4996,10 +4991,10 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
-                QuantumFormat "," QuantumFormat "," QuantumFormat,
-                image->matte_color.red,image->matte_color.green,
-                image->matte_color.blue,image->matte_color.opacity);
+              (void) FormatLocaleString(color,MaxTextExtent,
+                "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
+                image->matte_color.green,image->matte_color.blue,
+                image->matte_color.alpha);
               s=newSVpv(color,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -5038,7 +5033,7 @@ Get(ref,...)
               if (image == (Image *) NULL)
                 continue;
               j=info ? info->image_info->monochrome :
-                IsMonochromeImage(image,&image->exception);
+                IsImageMonochrome(image,exception);
               s=newSViv(j);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -5084,7 +5079,7 @@ Get(ref,...)
                   char
                     geometry[MaxTextExtent];
 
-                  (void) FormatMagickString(geometry,MaxTextExtent,
+                  (void) FormatLocaleString(geometry,MaxTextExtent,
                     "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
                     (double) image->page.height,(double) image->page.x,(double)
                     image->page.y);
@@ -5119,30 +5114,27 @@ Get(ref,...)
                 x,
                 y;
 
-              register const PixelPacket
+              register const Quantum
                 *p;
 
-              register const IndexPacket
-                *indexes;
-
               if (image == (Image *) NULL)
                 break;
               x=0;
               y=0;
               items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
+              (void) items;
               p=GetVirtualPixels(image,x,y,1,1,exception);
-              indexes=GetVirtualIndexQueue(image);
               if (image->colorspace != CMYKColorspace)
-                (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
+                (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
                   QuantumFormat "," QuantumFormat "," QuantumFormat,
-                  GetRedPixelComponent(p),GetGreenPixelComponent(p),
-                  GetBluePixelComponent(p),GetOpacityPixelComponent(p));
+                  GetPixelRed(image,p),GetPixelGreen(image,p),
+                  GetPixelBlue(image,p),GetPixelAlpha(image,p));
               else
-                (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
+                (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
                   QuantumFormat "," QuantumFormat "," QuantumFormat ","
-                  QuantumFormat,GetRedPixelComponent(p),
-                  GetGreenPixelComponent(p),GetBluePixelComponent(p),
-                  GetIndexPixelComponent(indexes),GetOpacityPixelComponent(p));
+                  QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
+                  GetPixelBlue(image,p),GetPixelBlack(image,p),
+                  GetPixelAlpha(image,p));
               s=newSVpv(tuple,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -5206,7 +5198,7 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
+              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
                 image->chromaticity.red_primary.x,
                 image->chromaticity.red_primary.y);
               s=newSVpv(color,0);
@@ -5234,20 +5226,6 @@ Get(ref,...)
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
-          if (LocaleCompare(attribute,"subimage") == 0)
-            {
-              if (info)
-                s=newSViv((ssize_t) info->image_info->subimage);
-              PUSHs(s ? sv_2mortal(s) : &sv_undef);
-              continue;
-            }
-          if (LocaleCompare(attribute,"subrange") == 0)
-            {
-              if (info)
-                s=newSViv((ssize_t) info->image_info->subrange);
-              PUSHs(s ? sv_2mortal(s) : &sv_undef);
-              continue;
-            }
           if (LocaleCompare(attribute,"server") == 0)  /* same as display */
             {
               if (info && info->image_info->server_name)
@@ -5283,8 +5261,8 @@ Get(ref,...)
 
               if (image == (Image *) NULL)
                 break;
-              (void) SignatureImage(image);
-              value=GetImageProperty(image,"Signature");
+              (void) SignatureImage(image,exception);
+              value=GetImageProperty(image,"Signature",exception);
               if (value != (const char *) NULL)
                 s=newSVpv(value,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -5304,13 +5282,6 @@ Get(ref,...)
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
-          if (LocaleCompare(attribute,"tile") == 0)
-            {
-              if (info && info->image_info->tile)
-                s=newSVpv(info->image_info->tile,0);
-              PUSHs(s ? sv_2mortal(s) : &sv_undef);
-              continue;
-            }
           if (LocaleCompare(attribute,"texture") == 0)
             {
               if (info && info->image_info->texture)
@@ -5322,7 +5293,7 @@ Get(ref,...)
             {
               s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
               if (image != (Image *) NULL)
-                s=newSVnv(GetImageTotalInkDensity(image));
+                s=newSVnv(GetImageTotalInkDensity(image,exception));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5330,10 +5301,10 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
-                QuantumFormat "," QuantumFormat "," QuantumFormat,
-                image->transparent_color.red,image->transparent_color.green,
-                image->transparent_color.blue,image->transparent_color.opacity);
+              (void) FormatLocaleString(color,MaxTextExtent,
+                "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
+                image->transparent_color.green,image->transparent_color.blue,
+                image->transparent_color.alpha);
               s=newSVpv(color,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -5342,7 +5313,7 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              j=(ssize_t) GetImageType(image,&image->exception);
+              j=(ssize_t) GetImageType(image,exception);
               s=newSViv(j);
               (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
               SvIOK_on(s);
@@ -5430,7 +5401,7 @@ Get(ref,...)
             {
               if (image == (Image *) NULL)
                 break;
-              (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
+              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
                 image->chromaticity.white_point.x,
                 image->chromaticity.white_point.y);
               s=newSVpv(color,0);
@@ -5454,7 +5425,7 @@ Get(ref,...)
           if (LocaleCompare(attribute,"x-resolution") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSVnv(image->x_resolution);
+                s=newSVnv(image->resolution.x);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5468,7 +5439,7 @@ Get(ref,...)
           if (LocaleCompare(attribute,"y-resolution") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSVnv(image->y_resolution);
+                s=newSVnv(image->resolution.y);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5484,7 +5455,7 @@ Get(ref,...)
           attribute)
       else
         {
-          value=GetImageProperty(image,attribute);
+          value=GetImageProperty(image,attribute,exception);
           if (value != (const char *) NULL)
             {
               s=newSVpv(value,0);
@@ -5500,7 +5471,7 @@ Get(ref,...)
                    *meta;
 
                  meta=InterpretImageProperties(info ? info->image_info :
-                   (ImageInfo *) NULL,image,attribute);
+                   (ImageInfo *) NULL,image,attribute,exception);
                  s=newSVpv(meta,0);
                  PUSHs(s ? sv_2mortal(s) : &sv_undef);
                  meta=(char *) RelinquishMagickMemory(meta);
@@ -5826,7 +5797,7 @@ GetVirtualPixels(ref,...)
 #                                                                             #
 #                                                                             #
 #                                                                             #
-#   G e t A u t h e n t i c I n d e x Q u e u e                               #
+#   G e t A u t h e n t i c M e t a c o n t e n t                             #
 #                                                                             #
 #                                                                             #
 #                                                                             #
@@ -5834,12 +5805,12 @@ GetVirtualPixels(ref,...)
 #
 #
 void *
-GetAuthenticIndexQueue(ref,...)
+GetAuthenticMetacontent(ref,...)
   Image::Magick ref = NO_INIT
   ALIAS:
-    getauthenticindexqueue = 1
-    GetIndexes = 2
-    getindexes = 3
+    getauthenticmetacontent = 1
+    GetMetacontent = 2
+    getmetacontent = 3
   CODE:
   {
     ExceptionInfo
@@ -5878,7 +5849,7 @@ GetAuthenticIndexQueue(ref,...)
         goto PerlException;
       }
 
-    blob=(void *) GetAuthenticIndexQueue(image);
+    blob=(void *) GetAuthenticMetacontent(image);
     if (blob != (void *) NULL)
       goto PerlEnd;
 
@@ -5898,7 +5869,7 @@ GetAuthenticIndexQueue(ref,...)
 #                                                                             #
 #                                                                             #
 #                                                                             #
-#   G e t V i r t u a l I n d e x Q u e u e                                   #
+#   G e t V i r t u a l M e t a c o n t e n t                                 #
 #                                                                             #
 #                                                                             #
 #                                                                             #
@@ -5906,10 +5877,10 @@ GetAuthenticIndexQueue(ref,...)
 #
 #
 void *
-GetVirtualIndexQueue(ref,...)
+GetVirtualMetacontent(ref,...)
   Image::Magick ref = NO_INIT
   ALIAS:
-    getvirtualindexqueue = 1
+    getvirtualmetacontent = 1
   CODE:
   {
     ExceptionInfo
@@ -5948,7 +5919,7 @@ GetVirtualIndexQueue(ref,...)
         goto PerlException;
       }
 
-    blob=(void *) GetVirtualIndexQueue(image);
+    blob=(void *) GetVirtualMetacontent(image);
     if (blob != (void *) NULL)
       goto PerlEnd;
 
@@ -5990,15 +5961,12 @@ Histogram(ref,...)
     char
       message[MaxTextExtent];
 
-    ColorPacket
+    PixelInfo
       *histogram;
 
     ExceptionInfo
       *exception;
 
-    HV
-      *hv;
-
     Image
       *image;
 
@@ -6012,7 +5980,6 @@ Histogram(ref,...)
       *info;
 
     SV
-      *av_reference,
       *perl_exception,
       *reference;
 
@@ -6031,9 +5998,7 @@ Histogram(ref,...)
         goto PerlException;
       }
     reference=SvRV(ST(0));
-    hv=SvSTASH(reference);
     av=newAV();
-    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
     image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
     if (image == (Image *) NULL)
@@ -6046,36 +6011,36 @@ Histogram(ref,...)
     count=0;
     for ( ; image; image=image->next)
     {
-      histogram=GetImageHistogram(image,&number_colors,&image->exception);
-      if (histogram == (ColorPacket *) NULL)
+      histogram=GetImageHistogram(image,&number_colors,exception);
+      if (histogram == (PixelInfo *) NULL)
         continue;
       count+=(ssize_t) number_colors;
       EXTEND(sp,6*count);
       for (i=0; i < (ssize_t) number_colors; i++)
       {
-        (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
-          histogram[i].pixel.red);
+        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
+          histogram[i].red);
         PUSHs(sv_2mortal(newSVpv(message,0)));
-        (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
-          histogram[i].pixel.green);
+        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
+          histogram[i].green);
         PUSHs(sv_2mortal(newSVpv(message,0)));
-        (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
-          histogram[i].pixel.blue);
+        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
+          histogram[i].blue);
         PUSHs(sv_2mortal(newSVpv(message,0)));
         if (image->colorspace == CMYKColorspace)
           {
-            (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
-              histogram[i].index);
+            (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
+              histogram[i].black);
             PUSHs(sv_2mortal(newSVpv(message,0)));
           }
-        (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
-          histogram[i].pixel.opacity);
+        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
+          histogram[i].alpha);
         PUSHs(sv_2mortal(newSVpv(message,0)));
-        (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double)
+        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
           histogram[i].count);
         PUSHs(sv_2mortal(newSVpv(message,0)));
       }
-      histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
+      histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
     }
 
   PerlException:
@@ -6110,9 +6075,6 @@ GetPixel(ref,...)
     char
       *attribute;
 
-    ChannelType
-      channel;
-
     ExceptionInfo
       *exception;
 
@@ -6125,10 +6087,7 @@ GetPixel(ref,...)
     RectangleInfo
       region;
 
-    register const IndexPacket
-      *indexes;
-
-    register const PixelPacket
+    register const Quantum
       *p;
 
     register ssize_t
@@ -6159,7 +6118,6 @@ GetPixel(ref,...)
           PackageName);
         goto PerlException;
       }
-    channel=DefaultChannels;
     normalize=MagickTrue;
     region.x=0;
     region.y=0;
@@ -6187,7 +6145,7 @@ GetPixel(ref,...)
                     SvPV(ST(i),na));
                   return;
                 }
-               channel=(ChannelType) option;
+              SetPixelChannelMapMask(image,(ChannelType) option);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -6259,28 +6217,27 @@ GetPixel(ref,...)
       }
     }
     p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
-    if (p == (const PixelPacket *) NULL)
+    if (p == (const Quantum *) NULL)
       PUSHs(&sv_undef);
     else
       {
         double
           scale;
 
-        indexes=GetVirtualIndexQueue(image);
         scale=1.0;
         if (normalize != MagickFalse)
           scale=1.0/QuantumRange;
-        if ((channel & RedChannel) != 0)
-          PUSHs(sv_2mortal(newSVnv(scale*GetRedPixelComponent(p))));
-        if ((channel & GreenChannel) != 0)
-          PUSHs(sv_2mortal(newSVnv(scale*GetGreenPixelComponent(p))));
-        if ((channel & BlueChannel) != 0)
-          PUSHs(sv_2mortal(newSVnv(scale*GetBluePixelComponent(p))));
-        if (((channel & IndexChannel) != 0) &&
+        if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
+          PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
+        if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
+          PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
+        if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
+          PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
+        if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
             (image->colorspace == CMYKColorspace))
-          PUSHs(sv_2mortal(newSVnv(scale*GetIndexPixelComponent(indexes))));
-        if ((channel & OpacityChannel) != 0)
-          PUSHs(sv_2mortal(newSVnv(scale*GetOpacityPixelComponent(p))));
+          PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
+        if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
+          PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
       }
 
   PerlException:
@@ -6620,7 +6577,7 @@ ImageToBlob(ref,...)
       next->scene=scene++;
     }
     SetImageInfo(package_info->image_info,(unsigned int)
-      GetImageListLength(image),&image->exception);
+      GetImageListLength(image),exception);
     EXTEND(sp,(ssize_t) GetImageListLength(image));
     for ( ; image; image=image->next)
     {
@@ -6685,9 +6642,6 @@ Layers(ref,...)
       *image,
       *layers;
 
-    MagickBooleanType
-      dither;
-
     ImageLayerMethod
       method;
 
@@ -6732,7 +6686,6 @@ Layers(ref,...)
         goto PerlException;
       }
     compose=image->compose;
-    dither=MagickFalse;
     method=OptimizeLayer;
     for (i=2; i < items; i+=2)
     {
@@ -6759,26 +6712,6 @@ Layers(ref,...)
             attribute);
           break;
         }
-        case 'D':
-        case 'd':
-        {
-          if (LocaleCompare(attribute,"dither") == 0)
-            {
-              sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
-                MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
-              if (sp < 0)
-                {
-                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
-                    SvPV(ST(i),na));
-                  break;
-                }
-              dither=(MagickBooleanType) sp;
-              break;
-            }
-          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
-            attribute);
-          break;
-        }
         case 'M':
         case 'm':
         {
@@ -6815,7 +6748,7 @@ Layers(ref,...)
       case CompareOverlayLayer:
       default:
       {
-        layers=CompareImageLayers(image,method,exception);
+        layers=CompareImagesLayers(image,method,exception);
         break;
       }
       case MergeLayer:
@@ -6843,19 +6776,16 @@ Layers(ref,...)
       case OptimizeTransLayer:
       {
         OptimizeImageTransparency(image,exception);
-        InheritException(&(image->exception),exception);
         break;
       }
       case RemoveDupsLayer:
       {
         RemoveDuplicateLayers(&image,exception);
-        InheritException(&(image->exception),exception);
         break;
       }
       case RemoveZeroLayer:
       {
         RemoveZeroDelayLayers(&image,exception);
-        InheritException(&(image->exception),exception);
         break;
       }
       case OptimizeLayer:
@@ -6869,19 +6799,16 @@ Layers(ref,...)
         layers=CoalesceImages(image,exception);
         if (layers == (Image *) NULL)
           break;
-        InheritException(&(layers->exception),exception);
         image=layers;
         layers=OptimizeImageLayers(image,exception);
         if (layers == (Image *) NULL)
           break;
-        InheritException(&(layers->exception),exception);
         image=DestroyImageList(image);
         image=layers;
         layers=(Image *) NULL;
         OptimizeImageTransparency(image,exception);
-        InheritException(&(image->exception),exception);
         quantize_info=AcquireQuantizeInfo(info->image_info);
-        (void) RemapImages(quantize_info,image,(Image *) NULL);
+        (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
         quantize_info=DestroyQuantizeInfo(quantize_info);
         break;
       }
@@ -6938,15 +6865,11 @@ Layers(ref,...)
           image->rows,image->gravity,&geometry);
         CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
         source=DestroyImageList(source);
-        InheritException(&(image->exception),exception);
         break;
       }
     }
     if (layers != (Image *) NULL)
-      {
-        InheritException(&(layers->exception),exception);
-        image=layers;
-      }
+      image=layers;
     if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
       goto PerlException;
     for ( ; image; image=image->next)
@@ -7053,7 +6976,7 @@ Mogrify(ref,...)
     Magnify            =  33
     MagnifyImage       =  34
     MedianFilter       =  35
-    MedianFilterImage  =  36
+    MedianConvolveImage  =  36
     Minify             =  37
     MinifyImage        =  38
     OilPaint           =  39
@@ -7230,8 +7153,8 @@ Mogrify(ref,...)
     ClipMaskImage      = 212
     LinearStretch      = 213
     LinearStretchImage = 214
-    RecolorImage       = 215
-    Recolor            = 216
+    ColorMatrix        = 215
+    ColorMatrixImage   = 216
     Mask               = 217
     MaskImage          = 218
     Polaroid           = 219
@@ -7273,23 +7196,19 @@ Mogrify(ref,...)
     AutoLevel          = 255
     AutoLevelImage     = 256
     LevelColors        = 257
-    LevelColorsImage   = 258
+    LevelImageColors   = 258
     Clamp              = 259
     ClampImage         = 260
-    Filter             = 261
-    FilterImage        = 262
-    BrightnessContrast = 263
-    BrightnessContrastImage = 264
-    Morphology         = 265
-    MorphologyImage    = 266
-    ColorMatrix        = 267
-    ColorMatrixImage   = 268
-    Color              = 269
-    ColorImage         = 270
-    Mode               = 271
-    ModeImage          = 272
-    Statistic          = 273
-    StatisticImage     = 274
+    BrightnessContrast = 261
+    BrightnessContrastImage = 262
+    Morphology         = 263
+    MorphologyImage    = 264
+    Color              = 265
+    ColorImage         = 266
+    Mode               = 267
+    ModeImage          = 268
+    Statistic          = 269
+    StatisticImage     = 270
     MogrifyRegion      = 666
   PPCODE:
   {
@@ -7302,7 +7221,8 @@ Mogrify(ref,...)
       message[MaxTextExtent];
 
     ChannelType
-      channel;
+      channel,
+      channel_mask;
 
     CompositeOperator
       compose;
@@ -7331,7 +7251,7 @@ Mogrify(ref,...)
     MagickStatusType
       flags;
 
-    PixelPacket
+    PixelInfo
       fill_color;
 
     RectangleInfo
@@ -7472,7 +7392,7 @@ Mogrify(ref,...)
         {
           if (SvTYPE(sv) != SVt_RV)
             {
-              (void) FormatMagickString(message,MaxTextExtent,
+              (void) FormatLocaleString(message,MaxTextExtent,
                 "invalid %.60s value",pp->method);
               ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
               goto continue_outer_loop;
@@ -7532,7 +7452,7 @@ Mogrify(ref,...)
             al->integer_reference=ParseChannelOption(SvPV(sv,na));
           if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
             {
-              (void) FormatMagickString(message,MaxTextExtent,
+              (void) FormatLocaleString(message,MaxTextExtent,
                 "invalid %.60s value",pp->method);
               ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
               goto continue_outer_loop;
@@ -7560,7 +7480,7 @@ Mogrify(ref,...)
       {
         default:
         {
-          (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double) ix);
+          (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
           ThrowPerlException(exception,OptionError,
             "UnrecognizedPerlMagickMethod",message);
           goto PerlException;
@@ -7571,7 +7491,7 @@ Mogrify(ref,...)
             argument_list[0].string_reference=(char *) NULL;
           (void) SetImageProperty(image,"comment",InterpretImageProperties(
             info ? info->image_info : (ImageInfo *) NULL,image,
-            argument_list[0].string_reference));
+            argument_list[0].string_reference,exception),exception);
           break;
         }
         case 2:  /* Label */
@@ -7580,36 +7500,56 @@ Mogrify(ref,...)
             argument_list[0].string_reference=(char *) NULL;
           (void) SetImageProperty(image,"label",InterpretImageProperties(
             info ? info->image_info : (ImageInfo *) NULL,image,
-            argument_list[0].string_reference));
+            argument_list[0].string_reference,exception),exception);
           break;
         }
         case 3:  /* AddNoise */
         {
+          double
+            attenuate;
+
           if (attribute_flag[0] == 0)
             argument_list[0].integer_reference=UniformNoise;
+          attenuate=1.0;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].integer_reference;
-          image=AddNoiseImageChannel(image,channel,(NoiseType)
-            argument_list[0].integer_reference,exception);
+            attenuate=argument_list[1].real_reference;
+          if (attribute_flag[2] != 0)
+            channel=(ChannelType) argument_list[2].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=AddNoiseImage(image,(NoiseType)
+            argument_list[0].integer_reference,attenuate,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 4:  /* Colorize */
         {
-          PixelPacket
+          PixelInfo
             target;
 
-          (void) GetOneVirtualPixel(image,0,0,&target,exception);
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
+          GetPixelInfo(image,&target);
+          (void) GetOneVirtualPixel(image,0,0,virtual_pixel,exception);
+          target.red=virtual_pixel[RedPixelChannel];
+          target.green=virtual_pixel[GreenPixelChannel];
+          target.blue=virtual_pixel[BluePixelChannel];
+          target.alpha=virtual_pixel[AlphaPixelChannel];
           if (attribute_flag[0] != 0)
-            (void) QueryColorDatabase(argument_list[0].string_reference,&target,
-              exception);
+            (void) QueryColorCompliance(argument_list[0].string_reference,
+              AllCompliance,&target,exception);
           if (attribute_flag[1] == 0)
             argument_list[1].string_reference="100%";
-          image=ColorizeImage(image,argument_list[1].string_reference,target,
+          image=ColorizeImage(image,argument_list[1].string_reference,&target,
             exception);
           break;
         }
         case 5:  /* Border */
         {
+          CompositeOperator
+            compose;
+
           geometry.width=0;
           geometry.height=0;
           if (attribute_flag[0] != 0)
@@ -7624,17 +7564,18 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            QueryColorDatabase(argument_list[3].string_reference,
-              &image->border_color,exception);
+            QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&image->border_color,exception);
           if (attribute_flag[4] != 0)
-            QueryColorDatabase(argument_list[4].string_reference,
-              &image->border_color,exception);
+            QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&image->border_color,exception);
           if (attribute_flag[5] != 0)
-            QueryColorDatabase(argument_list[5].string_reference,
-              &image->border_color,exception);
+            QueryColorCompliance(argument_list[5].string_reference,
+              AllCompliance,&image->border_color,exception);
+          compose=image->compose;
           if (attribute_flag[6] != 0)
-            image->compose=(CompositeOperator) argument_list[6].integer_reference;
-          image=BorderImage(image,&geometry,exception);
+            compose=(CompositeOperator) argument_list[6].integer_reference;
+          image=BorderImage(image,&geometry,compose,exception);
           break;
         }
         case 6:  /* Blur */
@@ -7651,9 +7592,14 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].integer_reference;
-          image=BlurImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,exception);
+            geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            channel=(ChannelType) argument_list[4].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 7:  /* Chop */
@@ -7688,8 +7634,8 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
-            image->fuzz=
-              SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           image=CropImage(image,&geometry,exception);
           break;
         }
@@ -7702,7 +7648,8 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0] != 0)
             geometry_info.rho=argument_list[0].real_reference;
-          image=EdgeImage(image,geometry_info.rho,exception);
+          image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
+            exception);
           break;
         }
         case 11:  /* Emboss */
@@ -7739,6 +7686,9 @@ Mogrify(ref,...)
         }
         case 15:  /* Frame */
         {
+          CompositeOperator
+            compose;
+
           FrameInfo
             frame_info;
 
@@ -7762,31 +7712,35 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             frame_info.outer_bevel=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
-            QueryColorDatabase(argument_list[5].string_reference,&fill_color,
-              exception);
+            QueryColorCompliance(argument_list[5].string_reference,
+              AllCompliance,&fill_color,exception);
           if (attribute_flag[6] != 0)
-            QueryColorDatabase(argument_list[6].string_reference,&fill_color,
-              exception);
+            QueryColorCompliance(argument_list[6].string_reference,
+              AllCompliance,&fill_color,exception);
           frame_info.x=(ssize_t) frame_info.width;
           frame_info.y=(ssize_t) frame_info.height;
           frame_info.width=image->columns+2*frame_info.x;
           frame_info.height=image->rows+2*frame_info.y;
           if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
             image->matte_color=fill_color;
+          compose=image->compose;
           if (attribute_flag[7] != 0)
-            image->compose=(CompositeOperator) argument_list[7].integer_reference;
-          image=FrameImage(image,&frame_info,exception);
+            compose=(CompositeOperator) argument_list[7].integer_reference;
+          image=FrameImage(image,&frame_info,compose,exception);
           break;
         }
         case 16:  /* Implode */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] == 0)
             argument_list[0].real_reference=0.5;
+          method=UndefinedInterpolatePixel;
           if (attribute_flag[1] != 0)
-            image->interpolate=(InterpolatePixelMethod)
-              argument_list[1].integer_reference;
+            method=(PixelInterpolateMethod) argument_list[1].integer_reference;
           image=ImplodeImage(image,argument_list[0].real_reference,
-            exception);
+            method,exception);
           break;
         }
         case 17:  /* Magnify */
@@ -7801,7 +7755,7 @@ Mogrify(ref,...)
               flags=ParseGeometry(argument_list[0].string_reference,
                 &geometry_info);
               if ((flags & SigmaValue) == 0)
-                geometry_info.sigma=1.0;
+                geometry_info.sigma=geometry_info.rho;
             }
           if (attribute_flag[1] != 0)
             geometry_info.rho=argument_list[1].real_reference;
@@ -7809,8 +7763,11 @@ Mogrify(ref,...)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
-          image=StatisticImageChannel(image,channel,MedianStatistic,
-            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 19:  /* Minify */
@@ -7822,8 +7779,10 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0] == 0)
             argument_list[0].real_reference=0.0;
+          if (attribute_flag[1] == 0)
+            argument_list[1].real_reference=1.0;
           image=OilPaintImage(image,argument_list[0].real_reference,
-            exception);
+            argument_list[1].real_reference,exception);
           break;
         }
         case 21:  /* ReduceNoise */
@@ -7841,8 +7800,11 @@ Mogrify(ref,...)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
-          image=StatisticImageChannel(image,channel,NonpeakStatistic,
-            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=StatisticImage(image,NonpeakStatistic,(size_t)
+            geometry_info.rho,(size_t) geometry_info.sigma,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 22:  /* Roll */
@@ -7862,14 +7824,14 @@ Mogrify(ref,...)
           if (attribute_flag[0] == 0)
             argument_list[0].real_reference=90.0;
           if (attribute_flag[1] != 0)
-            QueryColorDatabase(argument_list[1].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[1].string_reference,
+              AllCompliance,&image->background_color,exception);
           if (attribute_flag[2] != 0)
-            QueryColorDatabase(argument_list[2].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[2].string_reference,
+              AllCompliance,&image->background_color,exception);
           if (attribute_flag[3] != 0)
-            QueryColorDatabase(argument_list[3].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&image->background_color,exception);
           image=RotateImage(image,argument_list[0].real_reference,exception);
           break;
         }
@@ -7929,9 +7891,14 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].integer_reference;
-          image=SharpenImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,exception);
+            geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            channel=(ChannelType) argument_list[4].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 28:  /* Shear */
@@ -7948,30 +7915,41 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            QueryColorDatabase(argument_list[3].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&image->background_color,exception);
           if (attribute_flag[4] != 0)
-            QueryColorDatabase(argument_list[4].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&image->background_color,exception);
           image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
             exception);
           break;
         }
         case 29:  /* Spread */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] == 0)
             argument_list[0].real_reference=1.0;
-          image=SpreadImage(image,argument_list[0].real_reference,exception);
+          method=UndefinedInterpolatePixel;
+          if (attribute_flag[1] != 0)
+            method=(PixelInterpolateMethod) argument_list[1].integer_reference;
+          image=SpreadImage(image,argument_list[0].real_reference,method,
+            exception);
           break;
         }
         case 30:  /* Swirl */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] == 0)
             argument_list[0].real_reference=50.0;
+          method=UndefinedInterpolatePixel;
           if (attribute_flag[1] != 0)
-            image->interpolate=(InterpolatePixelMethod)
-              argument_list[1].integer_reference;
-          image=SwirlImage(image,argument_list[0].real_reference,exception);
+            method=(PixelInterpolateMethod) argument_list[1].integer_reference;
+          image=SwirlImage(image,argument_list[0].real_reference,
+            method,exception);
           break;
         }
         case 31:  /* Resize */
@@ -8009,7 +7987,8 @@ Mogrify(ref,...)
                 *text;
 
               text=InterpretImageProperties(info ? info->image_info :
-                (ImageInfo *) NULL,image,argument_list[0].string_reference);
+                (ImageInfo *) NULL,image,argument_list[0].string_reference,
+                exception);
               (void) CloneString(&draw_info->text,text);
               text=DestroyString(text);
             }
@@ -8022,20 +8001,20 @@ Mogrify(ref,...)
             (void) CloneString(&draw_info->density,
               argument_list[3].string_reference);
           if (attribute_flag[4] != 0)
-            (void) QueryColorDatabase(argument_list[4].string_reference,
-              &draw_info->undercolor,exception);
+            (void) QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&draw_info->undercolor,exception);
           if (attribute_flag[5] != 0)
             {
-              (void) QueryColorDatabase(argument_list[5].string_reference,
-                &draw_info->stroke,exception);
+              (void) QueryColorCompliance(argument_list[5].string_reference,
+                AllCompliance,&draw_info->stroke,exception);
               if (argument_list[5].image_reference != (Image *) NULL)
                 draw_info->stroke_pattern=CloneImage(
                   argument_list[5].image_reference,0,0,MagickTrue,exception);
             }
           if (attribute_flag[6] != 0)
             {
-              (void) QueryColorDatabase(argument_list[6].string_reference,
-                &draw_info->fill,exception);
+              (void) QueryColorCompliance(argument_list[6].string_reference,
+                AllCompliance,&draw_info->fill,exception);
               if (argument_list[6].image_reference != (Image *) NULL)
                 draw_info->fill_pattern=CloneImage(
                   argument_list[6].image_reference,0,0,MagickTrue,exception);
@@ -8050,10 +8029,11 @@ Mogrify(ref,...)
                 geometry_info.sigma=geometry_info.xi;
             }
           if (attribute_flag[8] != 0)
-            (void) QueryColorDatabase(argument_list[8].string_reference,
-              &draw_info->fill,exception);
+            (void) QueryColorCompliance(argument_list[8].string_reference,
+              AllCompliance,&draw_info->fill,exception);
           if (attribute_flag[11] != 0)
-            draw_info->gravity=(GravityType) argument_list[11].integer_reference;
+            draw_info->gravity=(GravityType)
+              argument_list[11].integer_reference;
           if (attribute_flag[25] != 0)
             {
               AV
@@ -8165,7 +8145,7 @@ Mogrify(ref,...)
               char
                 geometry[MaxTextExtent];
 
-              (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
+              (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
                 (double) argument_list[9].real_reference+draw_info->affine.tx,
                 (double) argument_list[10].real_reference+draw_info->affine.ty);
               (void) CloneString(&draw_info->geometry,geometry);
@@ -8210,7 +8190,7 @@ Mogrify(ref,...)
           if (attribute_flag[32] != 0)
             draw_info->direction=(DirectionType)
               argument_list[32].integer_reference;
-          (void) AnnotateImage(image,draw_info);
+          (void) AnnotateImage(image,draw_info,exception);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -8222,9 +8202,12 @@ Mogrify(ref,...)
           MagickBooleanType
             invert;
 
-          MagickPixelPacket
+          PixelInfo
             target;
 
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
           draw_info=CloneDrawInfo(info ? info->image_info :
             (ImageInfo *) NULL,(DrawInfo *) NULL);
           if (attribute_flag[0] != 0)
@@ -8235,24 +8218,28 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry.y=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            (void) QueryColorDatabase(argument_list[3].string_reference,
-              &draw_info->fill,exception);
-          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
+            (void) QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&draw_info->fill,exception);
+          (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
             exception);
+          target.red=virtual_pixel[RedPixelChannel];
+          target.green=virtual_pixel[GreenPixelChannel];
+          target.blue=virtual_pixel[BluePixelChannel];
+          target.alpha=virtual_pixel[AlphaPixelChannel];
           invert=MagickFalse;
           if (attribute_flag[4] != 0)
             {
-              QueryMagickColor(argument_list[4].string_reference,&target,
-                exception);
+              QueryColorCompliance(argument_list[4].string_reference,
+                AllCompliance,&target,exception);
               invert=MagickTrue;
             }
           if (attribute_flag[5] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[6] != 0)
             invert=(MagickBooleanType) argument_list[6].integer_reference;
-          (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
-            geometry.x,geometry.y,invert);
+          (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
+            geometry.y,invert,exception);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -8282,9 +8269,9 @@ Mogrify(ref,...)
           if (attribute_flag[6] != 0) /* opacity  */
             {
               if (compose != DissolveCompositeOp)
-                (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
-                  SiPrefixToDouble(argument_list[6].string_reference,
-                  QuantumRange)));
+                (void) SetImageAlpha(composite_image,(Quantum)
+                  StringToDoubleInterval(argument_list[6].string_reference,
+                  (double) QuantumRange+1.0),exception);
               else
                 {
                   CacheView
@@ -8299,7 +8286,7 @@ Mogrify(ref,...)
                   register ssize_t
                     x;
 
-                  register PixelPacket
+                  register Quantum
                     *q;
 
                   ssize_t
@@ -8311,10 +8298,11 @@ Mogrify(ref,...)
                   */
                   (void) CloneString(&image->geometry,
                     argument_list[6].string_reference);
-                  opacity=(Quantum) (QuantumRange-SiPrefixToDouble(
-                    argument_list[6].string_reference,QuantumRange));
+                  opacity=(Quantum) StringToDoubleInterval(
+                    argument_list[6].string_reference,(double) QuantumRange+
+                    1.0);
                   if (composite_image->matte != MagickTrue)
-                    (void) SetImageOpacity(composite_image,OpaqueOpacity);
+                    (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
                   composite_view=AcquireCacheView(composite_image);
                   for (y=0; y < (ssize_t) composite_image->rows ; y++)
                   {
@@ -8322,9 +8310,10 @@ Mogrify(ref,...)
                       composite_image->columns,1,exception);
                     for (x=0; x < (ssize_t) composite_image->columns; x++)
                     {
-                      if (q->opacity == OpaqueOpacity)
-                        q->opacity=ClampToQuantum(opacity);
-                      q++;
+                      if (GetPixelAlpha(image,q) == OpaqueAlpha)
+                        SetPixelAlpha(composite_image,ClampToQuantum(opacity),
+                          q);
+                      q+=GetPixelChannels(composite_image);
                     }
                     sync=SyncCacheViewAuthenticPixels(composite_view,exception);
                     if (sync == MagickFalse)
@@ -8334,10 +8323,10 @@ Mogrify(ref,...)
                 }
             }
           if (attribute_flag[9] != 0)    /* "color=>" */
-            QueryColorDatabase(argument_list[9].string_reference,
-              &composite_image->background_color,exception);
+            QueryColorCompliance(argument_list[9].string_reference,
+              AllCompliance,&composite_image->background_color,exception);
           if (attribute_flag[12] != 0) /* "interpolate=>" */
-            image->interpolate=(InterpolatePixelMethod)
+            image->interpolate=(PixelInterpolateMethod)
               argument_list[12].integer_reference;
           if (attribute_flag[13] != 0)   /* "args=>" */
             (void) SetImageArtifact(composite_image,"compose:args",
@@ -8359,7 +8348,8 @@ Mogrify(ref,...)
                if (rotate_image == (Image *) NULL)
                  break;
             }
-          if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
+          if ((attribute_flag[7] != 0) &&
+              (argument_list[7].integer_reference != 0)) /* tile */
             {
               ssize_t
                 x,
@@ -8378,9 +8368,11 @@ Mogrify(ref,...)
                 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
                 {
                   if (attribute_flag[8] != 0) /* rotate */
-                    (void) CompositeImage(image,compose,rotate_image,x,y);
+                    (void) CompositeImage(image,compose,rotate_image,x,y,
+                      exception);
                   else
-                    (void) CompositeImage(image,compose,composite_image,x,y);
+                    (void) CompositeImage(image,compose,composite_image,x,y,
+                      exception);
                 }
               if (attribute_flag[8] != 0) /* rotate */
                 rotate_image=DestroyImage(rotate_image);
@@ -8412,9 +8404,9 @@ Mogrify(ref,...)
                     Merge Y displacement into X displacement image.
                   */
                   composite_image=CloneImage(composite_image,0,0,MagickTrue,
-                    &image->exception);
+                    exception);
                   (void) CompositeImage(composite_image,CopyGreenCompositeOp,
-                    argument_list[10].image_reference,0,0);
+                    argument_list[10].image_reference,0,0,exception);
                 }
               else
                 {
@@ -8422,8 +8414,8 @@ Mogrify(ref,...)
                     Set a blending mask for the composition.
                   */
                   image->mask=CloneImage(argument_list[10].image_reference,0,0,
-                    MagickTrue,&image->exception);
-                  (void) NegateImage(image->mask,MagickFalse);
+                    MagickTrue,exception);
+                  (void) NegateImage(image->mask,MagickFalse,exception);
                 }
             }
           if (attribute_flag[11] != 0) /* channel */
@@ -8431,15 +8423,16 @@ Mogrify(ref,...)
           /*
             Composite two images (normal composition).
           */
-          (void) FormatMagickString(composite_geometry,MaxTextExtent,
+          (void) FormatLocaleString(composite_geometry,MaxTextExtent,
             "%.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);
+          channel_mask=SetPixelChannelMask(image,channel);
           if (attribute_flag[8] == 0) /* no rotate */
-            CompositeImageChannel(image,channel,compose,composite_image,
-              geometry.x,geometry.y);
+            CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
+              exception);
           else
             {
               /*
@@ -8449,8 +8442,8 @@ Mogrify(ref,...)
                 composite_image->columns)/2;
               geometry.y-=(ssize_t) (rotate_image->rows-
                 composite_image->rows)/2;
-              CompositeImageChannel(image,channel,compose,rotate_image,
-                geometry.x,geometry.y);
+              CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
+                exception);
               rotate_image=DestroyImage(rotate_image);
             }
           if (attribute_flag[10] != 0) /* mask */
@@ -8461,6 +8454,7 @@ Mogrify(ref,...)
               else
                 image->mask=DestroyImage(image->mask);
             }
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 36:  /* Contrast */
@@ -8468,14 +8462,15 @@ Mogrify(ref,...)
           if (attribute_flag[0] == 0)
             argument_list[0].integer_reference=0;
           (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
-            MagickTrue : MagickFalse);
+            MagickTrue : MagickFalse,exception);
           break;
         }
         case 37:  /* CycleColormap */
         {
           if (attribute_flag[0] == 0)
             argument_list[0].integer_reference=6;
-          (void) CycleColormapImage(image,argument_list[0].integer_reference);
+          (void) CycleColormapImage(image,argument_list[0].integer_reference,
+            exception);
           break;
         }
         case 38:  /* Draw */
@@ -8520,16 +8515,16 @@ Mogrify(ref,...)
             }
           if (attribute_flag[3] != 0)
             {
-              (void) QueryColorDatabase(argument_list[3].string_reference,
-                &draw_info->stroke,exception);
+              (void) QueryColorCompliance(argument_list[3].string_reference,
+                AllCompliance,&draw_info->stroke,exception);
               if (argument_list[3].image_reference != (Image *) NULL)
                 draw_info->stroke_pattern=CloneImage(
                   argument_list[3].image_reference,0,0,MagickTrue,exception);
             }
           if (attribute_flag[4] != 0)
             {
-              (void) QueryColorDatabase(argument_list[4].string_reference,
-                &draw_info->fill,exception);
+              (void) QueryColorCompliance(argument_list[4].string_reference,
+                AllCompliance,&draw_info->fill,exception);
               if (argument_list[4].image_reference != (Image *) NULL)
                 draw_info->fill_pattern=CloneImage(
                   argument_list[4].image_reference,0,0,MagickTrue,exception);
@@ -8540,8 +8535,8 @@ Mogrify(ref,...)
             (void) CloneString(&draw_info->font,
               argument_list[6].string_reference);
           if (attribute_flag[7] != 0)
-            (void) QueryColorDatabase(argument_list[7].string_reference,
-              &draw_info->border_color,exception);
+            (void) QueryColorCompliance(argument_list[7].string_reference,
+              AllCompliance,&draw_info->border_color,exception);
           if (attribute_flag[8] != 0)
             draw_info->affine.tx=argument_list[8].real_reference;
           if (attribute_flag[9] != 0)
@@ -8683,7 +8678,7 @@ Mogrify(ref,...)
                 }
             }
           if (attribute_flag[23] != 0)
-            image->interpolate=(InterpolatePixelMethod)
+            image->interpolate=(PixelInterpolateMethod)
               argument_list[23].integer_reference;
           if ((attribute_flag[24] != 0) &&
               (draw_info->fill_pattern != (Image *) NULL))
@@ -8715,7 +8710,7 @@ Mogrify(ref,...)
           if (attribute_flag[32] != 0)
             draw_info->direction=(DirectionType)
               argument_list[32].integer_reference;
-          DrawImage(image,draw_info);
+          DrawImage(image,draw_info,exception);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -8723,7 +8718,9 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          EqualizeImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          EqualizeImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 40:  /* Gamma */
@@ -8738,17 +8735,14 @@ Mogrify(ref,...)
             argument_list[4].real_reference=1.0;
           if (attribute_flag[0] == 0)
             {
-              (void) FormatMagickString(message,MaxTextExtent,
+              (void) FormatLocaleString(message,MaxTextExtent,
                 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
                 (double) argument_list[3].real_reference,
                 (double) argument_list[4].real_reference);
               argument_list[0].string_reference=message;
             }
-          if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
-            (void) GammaImage(image,argument_list[0].string_reference);
-          else
-            (void) GammaImageChannel(image,channel,
-              StringToDouble(argument_list[0].string_reference,(char **) NULL));
+          (void) GammaImage(image,StringToDouble(
+            argument_list[0].string_reference,(char **) NULL),exception);
           break;
         }
         case 41:  /* Map */
@@ -8770,7 +8764,7 @@ Mogrify(ref,...)
             quantize_info->dither_method=(DitherMethod)
               argument_list[2].integer_reference;
           (void) RemapImages(quantize_info,image,
-            argument_list[0].image_reference);
+            argument_list[0].image_reference,exception);
           quantize_info=DestroyQuantizeInfo(quantize_info);
           break;
         }
@@ -8782,12 +8776,14 @@ Mogrify(ref,...)
           MagickBooleanType
             invert;
 
-          MagickPixelPacket
+          PixelInfo
             target;
 
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
           draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
             (DrawInfo *) NULL);
-          if (attribute_flag[0] != 0)
           if (attribute_flag[0] != 0)
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
@@ -8796,23 +8792,30 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry.y=argument_list[2].integer_reference;
           if (image->matte == MagickFalse)
-            (void) SetImageOpacity(image,OpaqueOpacity);
-          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
+            (void) SetImageAlpha(image,OpaqueAlpha,exception);
+          (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
             exception);
+          target.red=virtual_pixel[RedPixelChannel];
+          target.green=virtual_pixel[GreenPixelChannel];
+          target.blue=virtual_pixel[BluePixelChannel];
+          target.alpha=virtual_pixel[AlphaPixelChannel];
           if (attribute_flag[4] != 0)
-            QueryMagickColor(argument_list[4].string_reference,&target,
-              exception);
+            QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&target,exception);
           if (attribute_flag[3] != 0)
-            target.opacity=SiPrefixToDouble(argument_list[3].string_reference,
-              QuantumRange);
+            target.alpha=StringToDoubleInterval(
+              argument_list[3].string_reference,(double) (double) QuantumRange+
+              1.0);
           if (attribute_flag[5] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           invert=MagickFalse;
           if (attribute_flag[6] != 0)
             invert=(MagickBooleanType) argument_list[6].integer_reference;
-          (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
-            geometry.x,geometry.y,invert);
+          channel_mask=SetPixelChannelMask(image,AlphaChannel);
+          (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
+            geometry.y,invert,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -8821,10 +8824,6 @@ Mogrify(ref,...)
           char
             modulate[MaxTextExtent];
 
-          ColorspaceType
-            colorspace;
-
-          colorspace=image->colorspace;
           geometry_info.rho=100.0;
           geometry_info.sigma=100.0;
           geometry_info.xi=100.0;
@@ -8837,25 +8836,27 @@ Mogrify(ref,...)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             {
-              (void) SetImageColorspace(image,HWBColorspace);
               geometry_info.sigma=argument_list[3].real_reference;
+              SetImageArtifact(image,"modulate:colorspace","HWB");
             }
           if (attribute_flag[4] != 0)
-            geometry_info.rho=argument_list[4].real_reference;
+            {
+              geometry_info.rho=argument_list[4].real_reference;
+              SetImageArtifact(image,"modulate:colorspace","HSB");
+            }
           if (attribute_flag[5] != 0)
             {
-              (void) SetImageColorspace(image,HSLColorspace);
               geometry_info.sigma=argument_list[5].real_reference;
+              SetImageArtifact(image,"modulate:colorspace","HSL");
             }
           if (attribute_flag[6] != 0)
             {
-              (void) SetImageColorspace(image,HWBColorspace);
               geometry_info.rho=argument_list[6].real_reference;
+              SetImageArtifact(image,"modulate:colorspace","HWB");
             }
-          (void) FormatMagickString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
+          (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
             geometry_info.rho,geometry_info.sigma,geometry_info.xi);
-          (void) ModulateImage(image,modulate);
-          (void) SetImageColorspace(image,colorspace);
+          (void) ModulateImage(image,modulate,exception);
           break;
         }
         case 44:  /* Negate */
@@ -8864,15 +8865,19 @@ Mogrify(ref,...)
             argument_list[0].integer_reference=0;
           if (attribute_flag[1] != 0)
             channel=(ChannelType) argument_list[1].integer_reference;
-          (void) NegateImageChannel(image,channel,
-            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
+            MagickTrue : MagickFalse,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 45:  /* Normalize */
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          NormalizeImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          NormalizeImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 46:  /* NumberColors */
@@ -8882,28 +8887,31 @@ Mogrify(ref,...)
           MagickBooleanType
             invert;
 
-          MagickPixelPacket
+          PixelInfo
             fill_color,
             target;
 
-          (void) QueryMagickColor("none",&target,exception);
-          (void) QueryMagickColor("none",&fill_color,exception);
+          (void) QueryColorCompliance("none",AllCompliance,&target,
+             exception);
+          (void) QueryColorCompliance("none",AllCompliance,&fill_color,
+            exception);
           if (attribute_flag[0] != 0)
-            (void) QueryMagickColor(argument_list[0].string_reference,
-              &target,exception);
+            (void) QueryColorCompliance(argument_list[0].string_reference,
+              AllCompliance,&target,exception);
           if (attribute_flag[1] != 0)
-            (void) QueryMagickColor(argument_list[1].string_reference,
-              &fill_color,exception);
+            (void) QueryColorCompliance(argument_list[1].string_reference,
+              AllCompliance,&fill_color,exception);
           if (attribute_flag[2] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[2].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
           invert=MagickFalse;
           if (attribute_flag[4] != 0)
             invert=(MagickBooleanType) argument_list[4].integer_reference;
-          (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
-            invert);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 48:  /* Quantize */
@@ -8926,13 +8934,14 @@ Mogrify(ref,...)
               MagickTrue : MagickFalse;
           if (attribute_flag[4] != 0)
             quantize_info->measure_error=
-              argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
+              argument_list[4].integer_reference != 0 ? MagickTrue :
+              MagickFalse;
           if (attribute_flag[5] != 0)
-            (void) QueryColorDatabase(argument_list[5].string_reference,
-              &image->transparent_color,exception);
+            (void) QueryColorCompliance(argument_list[5].string_reference,
+              AllCompliance,&image->transparent_color,exception);
           if (attribute_flag[5] && argument_list[5].integer_reference)
             {
-              (void) QuantizeImages(quantize_info,image);
+              (void) QuantizeImages(quantize_info,image,exception);
               goto PerlException;
             }
           if (attribute_flag[6] != 0)
@@ -8941,9 +8950,9 @@ Mogrify(ref,...)
           if ((image->storage_class == DirectClass) ||
               (image->colors > quantize_info->number_colors) ||
               (quantize_info->colorspace == GRAYColorspace))
-            (void) QuantizeImage(quantize_info,image);
+            (void) QuantizeImage(quantize_info,image,exception);
           else
-            CompressImageColormap(image);
+            CompressImageColormap(image,exception);
           quantize_info=DestroyQuantizeInfo(quantize_info);
           break;
         }
@@ -8958,8 +8967,9 @@ Mogrify(ref,...)
             geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] == 0)
             argument_list[3].integer_reference=1;
-          (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
-            0 ? MagickTrue : MagickFalse);
+          (void) RaiseImage(image,&geometry,
+            argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
+            exception);
           break;
         }
         case 50:  /* Segment */
@@ -8996,12 +9006,12 @@ Mogrify(ref,...)
             verbose=argument_list[4].integer_reference != 0 ?
               MagickTrue : MagickFalse;
           (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
-            smoothing_threshold);
+            smoothing_threshold,exception);
           break;
         }
         case 51:  /* Signature */
         {
-          (void) SignatureImage(image);
+          (void) SignatureImage(image,exception);
           break;
         }
         case 52:  /* Solarize */
@@ -9011,21 +9021,21 @@ Mogrify(ref,...)
             flags=ParseGeometry(argument_list[0].string_reference,
               &geometry_info);
           if (attribute_flag[1] != 0)
-            geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
-             QuantumRange);
-          (void) SolarizeImage(image,geometry_info.rho);
+            geometry_info.rho=StringToDoubleInterval(
+              argument_list[1].string_reference,(double) QuantumRange+1.0);
+          (void) SolarizeImage(image,geometry_info.rho,exception);
           break;
         }
         case 53:  /* Sync */
         {
-          (void) SyncImage(image);
+          (void) SyncImage(image,exception);
           break;
         }
         case 54:  /* Texture */
         {
           if (attribute_flag[0] == 0)
             break;
-          TextureImage(image,argument_list[0].image_reference);
+          TextureImage(image,argument_list[0].image_reference,exception);
           break;
         }
         case 55:  /* Evalute */
@@ -9040,8 +9050,10 @@ Mogrify(ref,...)
             op=(MagickEvaluateOperator) argument_list[1].integer_reference;
           if (attribute_flag[2] != MagickFalse)
             channel=(ChannelType) argument_list[2].integer_reference;
-          (void) EvaluateImageChannel(image,channel,op,
-            argument_list[0].real_reference,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) EvaluateImage(image,op,argument_list[0].real_reference,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 56:  /* Transparent */
@@ -9052,27 +9064,28 @@ Mogrify(ref,...)
           MagickBooleanType
             invert;
 
-          MagickPixelPacket
+          PixelInfo
             target;
 
-          (void) QueryMagickColor("none",&target,exception);
+          (void) QueryColorCompliance("none",AllCompliance,&target,
+            exception);
           if (attribute_flag[0] != 0)
-            (void) QueryMagickColor(argument_list[0].string_reference,&target,
-              exception);
-          opacity=TransparentOpacity;
+            (void) QueryColorCompliance(argument_list[0].string_reference,
+              AllCompliance,&target,exception);
+          opacity=TransparentAlpha;
           if (attribute_flag[1] != 0)
-            opacity=SiPrefixToDouble(argument_list[1].string_reference,
-              QuantumRange);
+            opacity=StringToDoubleInterval(argument_list[1].string_reference,
+              (double) QuantumRange+1.0);
           if (attribute_flag[2] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[2].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[3] == 0)
             argument_list[3].integer_reference=0;
           invert=MagickFalse;
           if (attribute_flag[3] != 0)
             invert=(MagickBooleanType) argument_list[3].integer_reference;
           (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
-            invert);
+            invert,exception);
           break;
         }
         case 57:  /* Threshold */
@@ -9084,9 +9097,11 @@ Mogrify(ref,...)
             argument_list[0].string_reference="50%";
           if (attribute_flag[1] != 0)
             channel=(ChannelType) argument_list[1].integer_reference;
-          threshold=SiPrefixToDouble(argument_list[0].string_reference,
-            QuantumRange);
-          (void) BilevelImageChannel(image,channel,threshold);
+          threshold=StringToDoubleInterval(argument_list[0].string_reference,
+            (double) QuantumRange+1.0);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) BilevelImage(image,threshold,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 58:  /* Charcoal */
@@ -9102,20 +9117,25 @@ Mogrify(ref,...)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
+          if (attribute_flag[3] != 0)
+            geometry_info.xi=argument_list[3].real_reference;
           image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
-            exception);
+            geometry_info.xi,exception);
           break;
         }
         case 59:  /* Trim */
         {
           if (attribute_flag[0] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[0].string_reference,(double) QuantumRange+1.0);
           image=TrimImage(image,exception);
           break;
         }
         case 60:  /* Wave */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] != 0)
             {
               flags=ParseGeometry(argument_list[0].string_reference,
@@ -9127,18 +9147,20 @@ Mogrify(ref,...)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
+          method=UndefinedInterpolatePixel;
           if (attribute_flag[3] != 0)
-            image->interpolate=(InterpolatePixelMethod)
-              argument_list[3].integer_reference;
+            method=(PixelInterpolateMethod) argument_list[3].integer_reference;
           image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
-            exception);
+            method,exception);
           break;
         }
         case 61:  /* Separate */
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          (void) SeparateImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) SeparateImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 63:  /* Stereo */
@@ -9173,7 +9195,7 @@ Mogrify(ref,...)
         }
         case 65:  /* Deconstruct */
         {
-          image=DeconstructImages(image,exception);
+          image=CompareImagesLayers(image,CompareAnyLayer,exception);
           break;
         }
         case 66:  /* GaussianBlur */
@@ -9190,44 +9212,70 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].integer_reference;
-          image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,exception);
+            geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            channel=(ChannelType) argument_list[4].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 67:  /* Convolve */
         {
-          AV
-            *av;
-
-          double
+          KernelInfo
             *kernel;
 
-          size_t
-            order;
-
-          if (attribute_flag[0] == 0)
+          kernel=(KernelInfo *) NULL;
+          if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
             break;
+          if (attribute_flag[0] != 0)
+            {
+              AV
+                *av;
+
+              size_t
+                order;
+
+              kernel=AcquireKernelInfo((const char *) NULL);
+              if (kernel == (KernelInfo *) NULL)
+                break;
+              av=(AV *) argument_list[0].array_reference;
+              order=(size_t) sqrt(av_len(av)+1);
+              kernel->width=order;
+              kernel->height=order;
+              kernel->values=(double *) AcquireAlignedMemory(order,order*
+                sizeof(*kernel->values));
+              if (kernel->values == (double *) NULL)
+                {
+                  kernel=DestroyKernelInfo(kernel);
+                  ThrowPerlException(exception,ResourceLimitFatalError,
+                    "MemoryAllocationFailed",PackageName);
+                  goto PerlException;
+                }
+              for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
+                kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
+              for ( ; j < (ssize_t) (order*order); j++)
+                kernel->values[j]=0.0;
+            }
           if (attribute_flag[1] != 0)
             channel=(ChannelType) argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            image->bias=SiPrefixToDouble(argument_list[2].string_reference,
-              QuantumRange);
-          av=(AV *) argument_list[0].array_reference;
-          order=(size_t) sqrt(av_len(av)+1);
-          kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
-          if (kernel == (double *) NULL)
+            image->bias=StringToDoubleInterval(
+              argument_list[2].string_reference,(double) QuantumRange+1.0);
+          if (attribute_flag[3] != 0)
             {
-              ThrowPerlException(exception,ResourceLimitFatalError,
-                "MemoryAllocationFailed",PackageName);
-              goto PerlException;
+              kernel=AcquireKernelInfo(argument_list[3].string_reference);
+              if (kernel == (KernelInfo *) NULL)
+                break;
             }
-          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
-            kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
-          for ( ; j < (ssize_t) (order*order); j++)
-            kernel[j]=0.0;
-          image=ConvolveImageChannel(image,channel,order,kernel,exception);
-          kernel=(double *) RelinquishMagickMemory(kernel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          kernel->bias=image->bias;
+          image=ConvolveImage(image,kernel,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
+          kernel=DestroyKernelInfo(kernel);
           break;
         }
         case 68:  /* Profile */
@@ -9261,7 +9309,7 @@ Mogrify(ref,...)
                     Remove a profile from the image.
                   */
                   (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
-                    MagickTrue);
+                    exception);
                   break;
                 }
               /*
@@ -9271,7 +9319,7 @@ Mogrify(ref,...)
               SetStringInfoDatum(profile,(const unsigned char *)
                 argument_list[1].string_reference);
               (void) ProfileImage(image,name,GetStringInfoDatum(profile),
-                (size_t) GetStringInfoLength(profile),MagickFalse);
+                (size_t) GetStringInfoLength(profile),exception);
               profile=DestroyStringInfo(profile);
               break;
             }
@@ -9281,7 +9329,7 @@ Mogrify(ref,...)
           profile_info=
             CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
           (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
-          profile_image=ReadImages(profile_info,&image->exception);
+          profile_image=ReadImages(profile_info,exception);
           if (profile_image == (Image *) NULL)
             break;
           ResetImageProfileIterator(profile_image);
@@ -9294,7 +9342,7 @@ Mogrify(ref,...)
             profile=GetImageProfile(profile_image,name);
             if (profile != (const StringInfo *) NULL)
               (void) ProfileImage(image,name,GetStringInfoDatum(profile),
-                (size_t) GetStringInfoLength(profile),MagickFalse);
+                (size_t) GetStringInfoLength(profile),exception);
             name=GetNextImageProfile(profile_image);
           }
           profile_image=DestroyImage(profile_image);
@@ -9324,8 +9372,11 @@ Mogrify(ref,...)
             geometry_info.psi=argument_list[4].real_reference;
           if (attribute_flag[5] != 0)
             channel=(ChannelType) argument_list[5].integer_reference;
-          image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,geometry_info.psi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 70:  /* MotionBlur */
@@ -9346,9 +9397,14 @@ Mogrify(ref,...)
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].real_reference;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].integer_reference;
-          image=MotionBlurImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,geometry_info.xi,exception);
+            geometry_info.psi=argument_list[4].real_reference;
+          if (attribute_flag[5] != 0)
+            channel=(ChannelType) argument_list[5].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,geometry_info.psi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 71:  /* OrderedDither */
@@ -9357,8 +9413,10 @@ Mogrify(ref,...)
             argument_list[0].string_reference="o8x8";
           if (attribute_flag[1] != 0)
             channel=(ChannelType) argument_list[1].integer_reference;
-          (void) OrderedPosterizeImageChannel(image,channel,
-            argument_list[0].string_reference,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 72:  /* Shave */
@@ -9413,7 +9471,9 @@ Mogrify(ref,...)
               argument_list[0].real_reference=argument_list[5].real_reference;
               attribute_flag[0]=attribute_flag[5];
             }
-          (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) LevelImage(image,black_point,white_point,gamma,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 74:  /* Clip */
@@ -9423,7 +9483,8 @@ Mogrify(ref,...)
           if (attribute_flag[1] == 0)
             argument_list[1].integer_reference=MagickTrue;
           (void) ClipImagePath(image,argument_list[0].string_reference,
-            argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
+            argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
+            exception);
           break;
         }
         case 75:  /* AffineTransform */
@@ -9536,11 +9597,11 @@ Mogrify(ref,...)
               current.rx*affine.tx+current.sy*affine.ty+current.ty;
           }
           if (attribute_flag[6] != 0)
-            image->interpolate=(InterpolatePixelMethod)
+            image->interpolate=(PixelInterpolateMethod)
               argument_list[6].integer_reference;
           if (attribute_flag[7] != 0)
-            QueryColorDatabase(argument_list[7].string_reference,
-              &image->background_color,exception);
+            QueryColorCompliance(argument_list[7].string_reference,
+              AllCompliance,&image->background_color,exception);
           image=AffineTransformImage(image,&draw_info->affine,exception);
           draw_info=DestroyDrawInfo(draw_info);
           break;
@@ -9554,9 +9615,10 @@ Mogrify(ref,...)
               goto PerlException;
             }
           if (attribute_flag[1] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
-              QuantumRange);
-          (void) IsImagesEqual(image,argument_list[0].image_reference);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[1].string_reference,(double) QuantumRange+1.0);
+          (void) IsImagesEqual(image,argument_list[0].image_reference,
+            exception);
           break;
         }
         case 77:  /* AdaptiveThreshold */
@@ -9575,8 +9637,7 @@ Mogrify(ref,...)
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].integer_reference;;
           image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
-            (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
-            exception);
+            (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
           break;
         }
         case 78:  /* Resample */
@@ -9604,16 +9665,16 @@ Mogrify(ref,...)
           if (attribute_flag[5] != 0)
             argument_list[5].real_reference=1.0;
           width=(size_t) (geometry_info.rho*image->columns/
-            (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
+            (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
           height=(size_t) (geometry_info.sigma*image->rows/
-            (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
+            (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
           image=ResizeImage(image,width,height,(FilterTypes)
             argument_list[3].integer_reference,argument_list[5].real_reference,
             exception);
           if (image != (Image *) NULL)
             {
-              image->x_resolution=geometry_info.rho;
-              image->y_resolution=geometry_info.sigma;
+              image->resolution.x=geometry_info.rho;
+              image->resolution.y=geometry_info.sigma;
             }
           break;
         }
@@ -9625,7 +9686,7 @@ Mogrify(ref,...)
             (void) SetImageArtifact(image,"identify:features",
               argument_list[1].string_reference);
           (void) IdentifyImage(image,argument_list[0].file_reference,
-            MagickTrue);
+            MagickTrue,exception);
           break;
         }
         case 80:  /* BlackThreshold */
@@ -9634,8 +9695,10 @@ Mogrify(ref,...)
             argument_list[0].string_reference="50%";
           if (attribute_flag[2] != 0)
             channel=(ChannelType) argument_list[2].integer_reference;
-          BlackThresholdImageChannel(image,channel,
-            argument_list[0].string_reference,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          BlackThresholdImage(image,argument_list[0].string_reference,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 81:  /* WhiteThreshold */
@@ -9644,8 +9707,10 @@ Mogrify(ref,...)
             argument_list[0].string_reference="50%";
           if (attribute_flag[2] != 0)
             channel=(ChannelType) argument_list[2].integer_reference;
-          WhiteThresholdImageChannel(image,channel,
-            argument_list[0].string_reference,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          WhiteThresholdImage(image,argument_list[0].string_reference,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 82:  /* RadialBlur */
@@ -9654,15 +9719,18 @@ Mogrify(ref,...)
             {
               flags=ParseGeometry(argument_list[0].string_reference,
                 &geometry_info);
-              if ((flags & SigmaValue) == 0)
-                geometry_info.sigma=1.0;
             }
           if (attribute_flag[1] != 0)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
-            channel=(ChannelType) argument_list[2].integer_reference;
-          image=RadialBlurImageChannel(image,channel,geometry_info.rho,
+            geometry_info.sigma=argument_list[2].real_reference;
+          if (attribute_flag[3] != 0)
+            channel=(ChannelType) argument_list[3].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
             exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 83:  /* Thumbnail */
@@ -9679,21 +9747,21 @@ Mogrify(ref,...)
         }
         case 84:  /* Strip */
         {
-          (void) StripImage(image);
+          (void) StripImage(image,exception);
           break;
         }
         case 85:  /* Tint */
         {
-          PixelPacket
-            target;
+          PixelInfo
+            tint;
 
-          (void) GetOneVirtualPixel(image,0,0,&target,exception);
+          GetPixelInfo(image,&tint);
           if (attribute_flag[0] != 0)
-            (void) QueryColorDatabase(argument_list[0].string_reference,&target,
-              exception);
+            (void) QueryColorCompliance(argument_list[0].string_reference,
+              AllCompliance,&tint,exception);
           if (attribute_flag[1] == 0)
             argument_list[1].string_reference="100";
-          image=TintImage(image,argument_list[1].string_reference,target,
+          image=TintImage(image,argument_list[1].string_reference,&tint,
             exception);
           break;
         }
@@ -9701,7 +9769,9 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          (void) SeparateImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) SeparateImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 87:  /* Splice */
@@ -9718,11 +9788,11 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[6] != 0)
-            (void) QueryColorDatabase(argument_list[6].string_reference,
-              &image->background_color,exception);
+            (void) QueryColorCompliance(argument_list[6].string_reference,
+              AllCompliance,&image->background_color,exception);
           if (attribute_flag[7] != 0)
             image->gravity=(GravityType) argument_list[7].integer_reference;
           image=SpliceImage(image,&geometry,exception);
@@ -9735,7 +9805,8 @@ Mogrify(ref,...)
           if (attribute_flag[1] == 0)
             argument_list[1].integer_reference=0;
           (void) PosterizeImage(image,argument_list[0].integer_reference,
-            argument_list[1].integer_reference ? MagickTrue : MagickFalse);
+            argument_list[1].integer_reference ? MagickTrue : MagickFalse,
+            exception);
           break;
         }
         case 89:  /* Shadow */
@@ -9775,7 +9846,7 @@ Mogrify(ref,...)
               (argument_list[2].integer_reference != 0))
             (void) SetImageArtifact(image,"identify:unique","true");
           (void) IdentifyImage(image,argument_list[0].file_reference,
-            MagickTrue);
+            MagickTrue,exception);
           break;
         }
         case 91:  /* SepiaTone */
@@ -9810,8 +9881,10 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
               MagickFalse;
-          (void) SigmoidalContrastImageChannel(image,channel,sharpen,
-            geometry_info.rho,geometry_info.sigma);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
+            geometry_info.sigma,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 93:  /* Extent */
@@ -9825,6 +9898,7 @@ Mogrify(ref,...)
 
               flags=ParseGravityGeometry(image,
                 argument_list[0].string_reference,&geometry,exception);
+              (void) flags;
               if (geometry.width == 0)
                 geometry.width=image->columns;
               if (geometry.height == 0)
@@ -9839,11 +9913,11 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[6] != 0)
-            (void) QueryColorDatabase(argument_list[6].string_reference,
-              &image->background_color,exception);
+            (void) QueryColorCompliance(argument_list[6].string_reference,
+              AllCompliance,&image->background_color,exception);
           image=ExtentImage(image,&geometry,exception);
           break;
         }
@@ -9869,8 +9943,8 @@ Mogrify(ref,...)
           if (attribute_flag[4] != 0)
             geometry_info.psi=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
-            (void) QueryColorDatabase(argument_list[5].string_reference,
-              &image->background_color,exception);
+            (void) QueryColorCompliance(argument_list[5].string_reference,
+              AllCompliance,&image->background_color,exception);
           image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
             (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
             0.5),exception);
@@ -9905,8 +9979,9 @@ Mogrify(ref,...)
             white_point=argument_list[2].real_reference;
           if (attribute_flag[4] != 0)
             channel=(ChannelType) argument_list[4].integer_reference;
-          (void) ContrastStretchImageChannel(image,channel,black_point,
-            white_point);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) ContrastStretchImage(image,black_point,white_point,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 96:  /* Sans0 */
@@ -9925,15 +10000,22 @@ Mogrify(ref,...)
                 &geometry_info);
               if ((flags & SigmaValue) == 0)
                 geometry_info.sigma=1.0;
+              if ((flags & XiValue) == 0)
+                geometry_info.xi=0.0;
             }
           if (attribute_flag[1] != 0)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].integer_reference;
-          image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,exception);
+            geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            channel=(ChannelType) argument_list[4].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=AdaptiveSharpenImage(image,geometry_info.rho,
+            geometry_info.sigma,geometry_info.xi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 99:  /* Transpose */
@@ -9998,15 +10080,22 @@ Mogrify(ref,...)
                 &geometry_info);
               if ((flags & SigmaValue) == 0)
                 geometry_info.sigma=1.0;
+              if ((flags & XiValue) == 0)
+                geometry_info.xi=0.0;
             }
           if (attribute_flag[1] != 0)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].integer_reference;
-          image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,exception);
+            geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            channel=(ChannelType) argument_list[4].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 103:  /* Sketch */
@@ -10026,8 +10115,10 @@ Mogrify(ref,...)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].real_reference;
+          if (attribute_flag[4] != 0)
+            geometry_info.psi=argument_list[4].real_reference;
           image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
-            geometry_info.xi,exception);
+            geometry_info.xi,geometry_info.psi,exception);
           break;
         }
         case 104:  /* UniqueColors */
@@ -10037,6 +10128,9 @@ Mogrify(ref,...)
         }
         case 105:  /* AdaptiveResize */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] != 0)
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
@@ -10051,8 +10145,11 @@ Mogrify(ref,...)
               argument_list[4].string_reference);
           if (attribute_flag[5] != 0)
             image->blur=argument_list[5].real_reference;
+          method=UndefinedInterpolatePixel;
+          if (attribute_flag[6] != 0)
+            method=(PixelInterpolateMethod) argument_list[6].integer_reference;
           image=AdaptiveResizeImage(image,geometry.width,geometry.height,
-            exception);
+            method,exception);
           break;
         }
         case 106:  /* ClipMask */
@@ -10065,7 +10162,7 @@ Mogrify(ref,...)
             }
           image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
             MagickTrue,exception);
-          (void) NegateImage(image->clip_mask,MagickFalse);
+          (void) NegateImage(image->clip_mask,MagickFalse,exception);
           break;
         }
         case 107:  /* LinearStretch */
@@ -10094,7 +10191,49 @@ Mogrify(ref,...)
             black_point=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
             white_point=argument_list[2].real_reference;
-          (void) LinearStretchImage(image,black_point,white_point);
+          (void) LinearStretchImage(image,black_point,white_point,exception);
+          break;
+        }
+        case 108:  /* ColorMatrix */
+        {
+          AV
+            *av;
+
+          double
+            *color_matrix;
+
+          KernelInfo
+            *kernel_info;
+
+          size_t
+            order;
+
+          if (attribute_flag[0] == 0)
+            break;
+          av=(AV *) argument_list[0].array_reference;
+          order=(size_t) sqrt(av_len(av)+1);
+          color_matrix=(double *) AcquireQuantumMemory(order,order*
+            sizeof(*color_matrix));
+          if (color_matrix == (double *) NULL)
+            {
+              ThrowPerlException(exception,ResourceLimitFatalError,
+                "MemoryAllocationFailed",PackageName);
+              goto PerlException;
+           }
+          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
+            color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
+          for ( ; j < (ssize_t) (order*order); j++)
+            color_matrix[j]=0.0;
+          kernel_info=AcquireKernelInfo((const char *) NULL);
+          if (kernel_info == (KernelInfo *) NULL)
+            break;
+          kernel_info->width=order;
+          kernel_info->height=order;
+          kernel_info->values=color_matrix;
+          image=ColorMatrixImage(image,kernel_info,exception);
+          kernel_info->values=(double *) NULL;
+          kernel_info=DestroyKernelInfo(kernel_info);
+          color_matrix=(double *) RelinquishMagickMemory(color_matrix);
           break;
         }
         case 109:  /* Mask */
@@ -10107,7 +10246,7 @@ Mogrify(ref,...)
             }
           image->mask=CloneImage(argument_list[0].image_reference,0,0,
             MagickTrue,exception);
-          (void) NegateImage(image->mask,MagickFalse);
+          (void) NegateImage(image->mask,MagickFalse,exception);
           break;
         }
         case 110:  /* Polaroid */
@@ -10118,12 +10257,15 @@ Mogrify(ref,...)
           double
             angle;
 
+          PixelInterpolateMethod
+            method;
+
           draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
             (DrawInfo *) NULL);
           if (attribute_flag[0] != 0)
             (void) SetImageProperty(image,"caption",InterpretImageProperties(
               info ? info->image_info : (ImageInfo *) NULL,image,
-              argument_list[0].string_reference));
+              argument_list[0].string_reference,exception),exception);
           angle=0.0;
           if (attribute_flag[1] != 0)
             angle=argument_list[1].real_reference;
@@ -10131,11 +10273,11 @@ Mogrify(ref,...)
             (void) CloneString(&draw_info->font,
               argument_list[2].string_reference);
           if (attribute_flag[3] != 0)
-            (void) QueryColorDatabase(argument_list[3].string_reference,
-              &draw_info->stroke,exception);
+            (void) QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&draw_info->stroke,exception);
           if (attribute_flag[4] != 0)
-            (void) QueryColorDatabase(argument_list[4].string_reference,
-              &draw_info->fill,exception);
+            (void) QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&draw_info->fill,exception);
           if (attribute_flag[5] != 0)
             draw_info->stroke_width=argument_list[5].real_reference;
           if (attribute_flag[6] != 0)
@@ -10143,9 +10285,12 @@ Mogrify(ref,...)
           if (attribute_flag[7] != 0)
             draw_info->gravity=(GravityType) argument_list[7].integer_reference;
           if (attribute_flag[8] != 0)
-            (void) QueryColorDatabase(argument_list[8].string_reference,
-              &image->background_color,exception);
-          image=PolaroidImage(image,draw_info,angle,exception);
+            (void) QueryColorCompliance(argument_list[8].string_reference,
+              AllCompliance,&image->background_color,exception);
+          method=UndefinedInterpolatePixel;
+          if (attribute_flag[9] != 0)
+            method=(PixelInterpolateMethod) argument_list[9].integer_reference;
+          image=PolaroidImage(image,draw_info,angle,method,exception);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -10157,9 +10302,12 @@ Mogrify(ref,...)
           MagickBooleanType
             invert;
 
-          MagickPixelPacket
+          PixelInfo
             target;
 
+          Quantum
+            virtual_pixel[MaxPixelChannels];
+
           draw_info=CloneDrawInfo(info ? info->image_info :
             (ImageInfo *) NULL,(DrawInfo *) NULL);
           if (attribute_flag[0] != 0)
@@ -10170,23 +10318,29 @@ Mogrify(ref,...)
           if (attribute_flag[2] != 0)
             geometry.y=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            (void) QueryColorDatabase(argument_list[3].string_reference,
-              &draw_info->fill,exception);
-          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
+            (void) QueryColorCompliance(argument_list[3].string_reference,
+              AllCompliance,&draw_info->fill,exception);
+          (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
             exception);
+          target.red=virtual_pixel[RedPixelChannel];
+          target.green=virtual_pixel[GreenPixelChannel];
+          target.blue=virtual_pixel[BluePixelChannel];
+          target.alpha=virtual_pixel[AlphaPixelChannel];
           if (attribute_flag[4] != 0)
-            QueryMagickColor(argument_list[4].string_reference,&target,
-              exception);
+            QueryColorCompliance(argument_list[4].string_reference,
+              AllCompliance,&target,exception);
           if (attribute_flag[5] != 0)
-            image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
-              QuantumRange);
+            image->fuzz=StringToDoubleInterval(
+              argument_list[5].string_reference,(double) QuantumRange+1.0);
           if (attribute_flag[6] != 0)
             channel=(ChannelType) argument_list[6].integer_reference;
           invert=MagickFalse;
           if (attribute_flag[7] != 0)
             invert=(MagickBooleanType) argument_list[7].integer_reference;
-          (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
-            geometry.y,invert);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
+            geometry.y,invert,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           draw_info=DestroyDrawInfo(draw_info);
           break;
         }
@@ -10238,16 +10392,24 @@ Mogrify(ref,...)
         }
         case 113:  /* Clut */
         {
+          PixelInterpolateMethod
+            method;
+
           if (attribute_flag[0] == 0)
             {
               ThrowPerlException(exception,OptionError,"ClutImageRequired",
                 PackageName);
               goto PerlException;
             }
+          method=UndefinedInterpolatePixel;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].integer_reference;
-          (void) ClutImageChannel(image,channel,
-            argument_list[0].image_reference);
+            method=(PixelInterpolateMethod) argument_list[1].integer_reference;
+          if (attribute_flag[2] != 0)
+            channel=(ChannelType) argument_list[2].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) ClutImage(image,argument_list[0].image_reference,method,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 114:  /* LiquidRescale */
@@ -10287,8 +10449,8 @@ Mogrify(ref,...)
             flags=ParseGeometry(argument_list[0].string_reference,
               &geometry_info);
           if (attribute_flag[1] != 0)
-            geometry_info.rho=SiPrefixToDouble(
-              argument_list[1].string_reference,QuantumRange);
+            geometry_info.rho=StringToDoubleInterval(
+              argument_list[1].string_reference,(double) QuantumRange+1.0);
           image=DeskewImage(image,geometry_info.rho,exception);
           break;
         }
@@ -10311,7 +10473,7 @@ Mogrify(ref,...)
             quantize_info->dither_method=(DitherMethod)
               argument_list[2].integer_reference;
           (void) RemapImages(quantize_info,image,
-            argument_list[0].image_reference);
+            argument_list[0].image_reference,exception);
           quantize_info=DestroyQuantizeInfo(quantize_info);
           break;
         }
@@ -10355,8 +10517,11 @@ Mogrify(ref,...)
               argument_list[2].integer_reference);
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
-          image=SparseColorImage(image,channel,method,number_coordinates,
-            coordinates,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=SparseColorImage(image,method,number_coordinates,coordinates,
+            exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
             virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
           coordinates=(double *) RelinquishMagickMemory(coordinates);
@@ -10425,9 +10590,14 @@ Mogrify(ref,...)
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].integer_reference;;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].integer_reference;
-          image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
-            geometry_info.sigma,geometry_info.xi,exception);
+            geometry_info.psi=argument_list[4].integer_reference;;
+          if (attribute_flag[5] != 0)
+            channel=(ChannelType) argument_list[5].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,geometry_info.psi,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 122:  /* HaldClut */
@@ -10440,8 +10610,10 @@ Mogrify(ref,...)
             }
           if (attribute_flag[1] != 0)
             channel=(ChannelType) argument_list[1].integer_reference;
-          (void) HaldClutImageChannel(image,channel,
-            argument_list[0].image_reference);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) HaldClutImage(image,argument_list[0].image_reference,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 123:  /* BlueShift */
@@ -10471,71 +10643,64 @@ Mogrify(ref,...)
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference=(char *) NULL;
           (void) ColorDecisionListImage(image,
-            argument_list[0].string_reference);
+            argument_list[0].string_reference,exception);
           break;
         }
         case 127:  /* AutoGamma */
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          (void) AutoGammaImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) AutoGammaImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 128:  /* AutoLevel */
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          (void) AutoLevelImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) AutoLevelImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 129:  /* LevelColors */
         {
-          MagickPixelPacket
+          PixelInfo
             black_point,
             white_point;
 
-          (void) QueryMagickColor("#000000",&black_point,exception);
-          (void) QueryMagickColor("#ffffff",&white_point,exception);
+          (void) QueryColorCompliance("#000000",AllCompliance,
+            &black_point,exception);
+          (void) QueryColorCompliance("#ffffff",AllCompliance,
+            &white_point,exception);
           if (attribute_flag[1] != 0)
-             (void) QueryMagickColor(argument_list[1].string_reference,
-               &black_point,exception);
+             (void) QueryColorCompliance(
+               argument_list[1].string_reference,AllCompliance,&black_point,
+               exception);
           if (attribute_flag[2] != 0)
-             (void) QueryMagickColor(argument_list[2].string_reference,
-               &white_point,exception);
+             (void) QueryColorCompliance(
+               argument_list[2].string_reference,AllCompliance,&white_point,
+               exception);
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
-          (void) LevelColorsImageChannel(image,channel,&black_point,
-            &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
-            MagickFalse);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) LevelImageColors(image,&black_point,&white_point,
+            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
+            exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
         case 130:  /* Clamp */
         {
           if (attribute_flag[0] != 0)
             channel=(ChannelType) argument_list[0].integer_reference;
-          (void) ClampImageChannel(image,channel);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) ClampImage(image,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
-        case 131:  /* Filter */
-        {
-          KernelInfo
-            *kernel;
-
-          if (attribute_flag[0] == 0)
-            break;
-          kernel=AcquireKernelInfo(argument_list[0].string_reference);
-          if (kernel == (KernelInfo *) NULL)
-            break;
-          if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].integer_reference;
-          if (attribute_flag[2] != 0)
-            image->bias=SiPrefixToDouble(argument_list[2].string_reference,
-              QuantumRange);
-          image=FilterImageChannel(image,channel,kernel,exception);
-          kernel=DestroyKernelInfo(kernel);
-          break;
-        }
-        case 132:  /* BrightnessContrast */
+        case 131:  /* BrightnessContrast */
         {
           double
             brightness,
@@ -10557,11 +10722,12 @@ Mogrify(ref,...)
             contrast=argument_list[2].real_reference;
           if (attribute_flag[4] != 0)
             channel=(ChannelType) argument_list[4].integer_reference;
-          (void) BrightnessContrastImageChannel(image,channel,brightness,
-            contrast);
+          channel_mask=SetPixelChannelMask(image,channel);
+          (void) BrightnessContrastImage(image,brightness,contrast,exception);
+          (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
-        case 133:  /* Morphology */
+        case 132:  /* Morphology */
         {
           KernelInfo
             *kernel;
@@ -10584,68 +10750,15 @@ Mogrify(ref,...)
             method=argument_list[2].integer_reference;
           iterations=1;
           if (attribute_flag[3] != 0)
-            iterations=argument_list[4].integer_reference;
-          image=MorphologyImageChannel(image,channel,method,iterations,kernel,
-            exception);
+            iterations=argument_list[3].integer_reference;
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=MorphologyImage(image,method,iterations,kernel,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           kernel=DestroyKernelInfo(kernel);
           break;
         }
-        case 108:  /* Recolor */
-        case 134:  /* ColorMatrix */
-        {
-          AV
-            *av;
-
-          double
-            *color_matrix;
-
-          KernelInfo
-            *kernel_info;
-
-          size_t
-            order;
-
-          if (attribute_flag[0] == 0)
-            break;
-          av=(AV *) argument_list[0].array_reference;
-          order=(size_t) sqrt(av_len(av)+1);
-          color_matrix=(double *) AcquireQuantumMemory(order,order*
-            sizeof(*color_matrix));
-          if (color_matrix == (double *) NULL)
-            {
-              ThrowPerlException(exception,ResourceLimitFatalError,
-                "MemoryAllocationFailed",PackageName);
-              goto PerlException;
-           }
-          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
-            color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
-          for ( ; j < (ssize_t) (order*order); j++)
-            color_matrix[j]=0.0;
-          kernel_info=AcquireKernelInfo("1");
-          if (kernel_info == (KernelInfo *) NULL)
-            break;
-          kernel_info->width=order;
-          kernel_info->height=order;
-          kernel_info->values=color_matrix;
-          image=ColorMatrixImage(image,kernel_info,exception);
-          kernel_info->values=(double *) NULL;
-          kernel_info=DestroyKernelInfo(kernel_info);
-          color_matrix=(double *) RelinquishMagickMemory(color_matrix);
-          break;
-        }
-        case 135:  /* Color */
-        {
-          MagickPixelPacket
-            color;
-
-          (void) QueryMagickColor("none",&color,exception);
-          if (attribute_flag[0] != 0)
-            (void) QueryMagickColor(argument_list[0].string_reference,
-              &color,exception);
-          (void) SetImageColor(image,&color);
-          break;
-        }
-        case 136:  /* Mode */
+        case 133:  /* Mode */
         {
           if (attribute_flag[0] != 0)
             {
@@ -10660,11 +10773,14 @@ Mogrify(ref,...)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             channel=(ChannelType) argument_list[3].integer_reference;
-          image=StatisticImageChannel(image,channel,ModeStatistic,
-            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
-        case 137:  /* Statistic */
+        case 134:  /* Statistic */
         {
           StatisticType
             statistic;
@@ -10685,8 +10801,11 @@ Mogrify(ref,...)
             channel=(ChannelType) argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
             statistic=(StatisticType) argument_list[4].integer_reference;
-          image=StatisticImageChannel(image,channel,statistic,
-            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
+          channel_mask=SetPixelChannelMask(image,channel);
+          image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,exception);
+          if (image != (Image *) NULL)
+            (void) SetPixelChannelMask(image,channel_mask);
           break;
         }
       }
@@ -10696,9 +10815,10 @@ Mogrify(ref,...)
         {
           /*
             Composite region.
-          */
+          */ 
           status=CompositeImage(region_image,CopyCompositeOp,image,
-            region_info.x,region_info.y);
+            region_info.x,region_info.y,exception);
+          (void) status;
           (void) CatchImageException(region_image);
           image=DestroyImage(image);
           image=region_image;
@@ -10709,6 +10829,8 @@ Mogrify(ref,...)
           if (next && (next != image))
             {
               image->next=next->next;
+              if (image->next != (Image *) NULL)
+                image->next->previous=image;
               DeleteImageFromRegistry(*pv,next);
             }
           sv_setiv(*pv,(IV) image);
@@ -10766,7 +10888,7 @@ Montage(ref,...)
       *image,
       *next;
 
-    MagickPixelPacket
+    PixelInfo
       transparent_color;
 
     MontageInfo
@@ -10817,7 +10939,8 @@ Montage(ref,...)
     */
     info=GetPackageInfo(aTHX_ (void *) av,info,exception);
     montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
-    (void) QueryMagickColor("none",&transparent_color,exception);
+    (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
+      exception);
     for (i=2; i < items; i+=2)
     {
       attribute=(char *) SvPV(ST(i-1),na);
@@ -10828,7 +10951,7 @@ Montage(ref,...)
         {
           if (LocaleCompare(attribute,"background") == 0)
             {
-              (void) QueryColorDatabase(SvPV(ST(i),na),
+              (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
                 &montage_info->background_color,exception);
               for (next=image; next; next=next->next)
                 next->background_color=montage_info->background_color;
@@ -10841,7 +10964,7 @@ Montage(ref,...)
             }
           if (LocaleCompare(attribute,"bordercolor") == 0)
             {
-              (void) QueryColorDatabase(SvPV(ST(i),na),
+              (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
                 &montage_info->border_color,exception);
               for (next=image; next; next=next->next)
                 next->border_color=montage_info->border_color;
@@ -10882,8 +11005,8 @@ Montage(ref,...)
         {
           if (LocaleCompare(attribute,"fill") == 0)
             {
-              (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
-                exception);
+              (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                &montage_info->fill,exception);
               break;
             }
           if (LocaleCompare(attribute,"font") == 0)
@@ -10962,7 +11085,7 @@ Montage(ref,...)
               for (next=image; next; next=next->next)
                 (void) SetImageProperty(next,"label",InterpretImageProperties(
                   info ? info->image_info : (ImageInfo *) NULL,next,
-                  SvPV(ST(i),na)));
+                  SvPV(ST(i),na),exception),exception);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -10974,7 +11097,7 @@ Montage(ref,...)
         {
           if (LocaleCompare(attribute,"mattecolor") == 0)
             {
-              (void) QueryColorDatabase(SvPV(ST(i),na),
+              (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
                 &montage_info->matte_color,exception);
               for (next=image; next; next=next->next)
                 next->matte_color=montage_info->matte_color;
@@ -10985,8 +11108,8 @@ Montage(ref,...)
               ssize_t
                 in;
 
-              in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
-                ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
+              in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
+                MagickModeOptions,MagickFalse,SvPV(ST(i),na));
               switch (in)
               {
                 default:
@@ -11052,8 +11175,8 @@ Montage(ref,...)
             }
           if (LocaleCompare(attribute,"stroke") == 0)
             {
-              (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
-                exception);
+              (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                &montage_info->stroke,exception);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -11089,13 +11212,14 @@ Montage(ref,...)
             }
           if (LocaleCompare(attribute,"transparent") == 0)
             {
-              MagickPixelPacket
+              PixelInfo
                 transparent_color;
 
-              QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
+              QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                &transparent_color,exception);
               for (next=image; next; next=next->next)
                 (void) TransparentPaintImage(next,&transparent_color,
-                  TransparentOpacity,MagickFalse);
+                  TransparentAlpha,MagickFalse,exception);
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -11114,10 +11238,10 @@ Montage(ref,...)
     montage_info=DestroyMontageInfo(montage_info);
     if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
       goto PerlException;
-    if (transparent_color.opacity != TransparentOpacity)
+    if (transparent_color.alpha != TransparentAlpha)
       for (next=image; next; next=next->next)
         (void) TransparentPaintImage(next,&transparent_color,
-          TransparentOpacity,MagickFalse);
+          TransparentAlpha,MagickFalse,exception);
     for (  ; image; image=image->next)
     {
       AddImageToRegistry(sv,image);
@@ -11344,9 +11468,9 @@ Mosaic(ref)
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
     info=GetPackageInfo(aTHX_ (void *) av,info,exception);
-    (void) CopyMagickString(image->filename,info->image_info->filename,
+    (void) CopyMagickString(info->image_info->filename,image->filename,
       MaxTextExtent);
-    SetImageInfo(info->image_info,0,&image->exception);
+    SetImageInfo(info->image_info,0,exception);
     exception=DestroyExceptionInfo(exception);
     SvREFCNT_dec(perl_exception);
     XSRETURN(1);
@@ -11391,9 +11515,6 @@ Ping(ref,...)
     ExceptionInfo
       *exception;
 
-    HV
-      *hv;
-
     Image
       *image,
       *next;
@@ -11457,7 +11578,6 @@ Ping(ref,...)
         goto PerlException;
       }
     reference=SvRV(ST(0));
-    hv=SvSTASH(reference);
     if (SvTYPE(reference) != SVt_PVAV)
       {
         ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
@@ -11698,7 +11818,7 @@ QueryColor(ref,...)
     ExceptionInfo
       *exception;
 
-    MagickPixelPacket
+    PixelInfo
       color;
 
     register ssize_t
@@ -11733,7 +11853,7 @@ QueryColor(ref,...)
     for (i=1; i < items; i++)
     {
       name=(char *) SvPV(ST(i),na);
-      if (QueryMagickColor(name,&color,exception) == MagickFalse)
+      if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
         {
           PUSHs(&sv_undef);
           continue;
@@ -11741,10 +11861,10 @@ QueryColor(ref,...)
       PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
       PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
       PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
-      if (color.matte != MagickFalse)
-        PUSHs(sv_2mortal(newSViv((size_t) floor(color.opacity+0.5))));
       if (color.colorspace == CMYKColorspace)
-        PUSHs(sv_2mortal(newSViv((size_t) floor(color.index+0.5))));
+        PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
+      if (color.matte != MagickFalse)
+        PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
     }
 
   PerlException:
@@ -11784,7 +11904,7 @@ QueryColorname(ref,...)
     Image
       *image;
 
-    PixelPacket
+    PixelInfo
       target_color;
 
     register ssize_t
@@ -11815,7 +11935,8 @@ QueryColorname(ref,...)
     EXTEND(sp,items);
     for (i=1; i < items; i++)
     {
-      (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
+      (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
+        exception);
       (void) QueryColorname(image,&target_color,SVGCompliance,message,
         exception);
       PUSHs(sv_2mortal(newSVpv(message,0)));
@@ -11916,7 +12037,7 @@ QueryFont(ref,...)
       else
         PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
           type_info->stretch),0)));
-      (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double)
+      (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
         type_info->weight);
       PUSHs(sv_2mortal(newSVpv(message,0)));
       if (type_info->encoding == (char *) NULL)
@@ -12105,8 +12226,8 @@ QueryFontMetrics(ref,...)
           if (LocaleCompare(attribute,"fill") == 0)
             {
               if (info)
-                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
-                  &image->exception);
+                (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                  &draw_info->fill,exception);
               break;
             }
           if (LocaleCompare(attribute,"font") == 0)
@@ -12227,8 +12348,8 @@ QueryFontMetrics(ref,...)
           if (LocaleCompare(attribute,"stroke") == 0)
             {
               if (info)
-                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
-                  &image->exception);
+                (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                  &draw_info->stroke,exception);
               break;
             }
           if (LocaleCompare(attribute,"style") == 0)
@@ -12325,10 +12446,10 @@ QueryFontMetrics(ref,...)
     if (draw_info->geometry == (char *) NULL)
       {
         draw_info->geometry=AcquireString((char *) NULL);
-        (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
+        (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
           "%.15g,%.15g",x,y);
       }
-    status=GetTypeMetrics(image,draw_info,&metrics);
+    status=GetTypeMetrics(image,draw_info,&metrics,exception);
     (void) CatchImageException(image);
     if (status == MagickFalse)
       PUSHs(&sv_undef);
@@ -12510,8 +12631,8 @@ QueryMultilineFontMetrics(ref,...)
           if (LocaleCompare(attribute,"fill") == 0)
             {
               if (info)
-                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
-                  &image->exception);
+                (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                  &draw_info->fill,exception);
               break;
             }
           if (LocaleCompare(attribute,"font") == 0)
@@ -12600,8 +12721,8 @@ QueryMultilineFontMetrics(ref,...)
           if (LocaleCompare(attribute,"stroke") == 0)
             {
               if (info)
-                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
-                  &image->exception);
+                (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
+                  &draw_info->stroke,exception);
               break;
             }
           if (LocaleCompare(attribute,"style") == 0)
@@ -12698,11 +12819,11 @@ QueryMultilineFontMetrics(ref,...)
     if (draw_info->geometry == (char *) NULL)
       {
         draw_info->geometry=AcquireString((char *) NULL);
-        (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
+        (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
           "%.15g,%.15g",x,y);
       }
-    status=GetMultilineTypeMetrics(image,draw_info,&metrics);
-    (void) CatchImageException(image);
+    status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
+    (void) CatchException(exception);
     if (status == MagickFalse)
       PUSHs(&sv_undef);
     else
@@ -13250,7 +13371,8 @@ SetPixel(ref,...)
       *attribute;
 
     ChannelType
-      channel;
+      channel,
+      channel_mask;
 
     ExceptionInfo
       *exception;
@@ -13264,13 +13386,10 @@ SetPixel(ref,...)
     RectangleInfo
       region;
 
-    register IndexPacket
-      *indexes;
-
     register ssize_t
       i;
 
-    register PixelPacket
+    register Quantum
       *q;
 
     ssize_t
@@ -13299,7 +13418,6 @@ SetPixel(ref,...)
         goto PerlException;
       }
     av=(AV *) NULL;
-    channel=DefaultChannels;
     normalize=MagickTrue;
     region.x=0;
     region.y=0;
@@ -13307,6 +13425,7 @@ SetPixel(ref,...)
     region.height=1;
     if (items == 1)
       (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
+    channel=DefaultChannels;
     for (i=2; i < items; i+=2)
     {
       attribute=(char *) SvPV(ST(i-1),na);
@@ -13327,7 +13446,7 @@ SetPixel(ref,...)
                     SvPV(ST(i),na));
                   return;
                 }
-               channel=(ChannelType) option;
+              channel=(ChannelType) option;
               break;
             }
           if (LocaleCompare(attribute,"color") == 0)
@@ -13337,7 +13456,7 @@ SetPixel(ref,...)
                   char
                     message[MaxTextExtent];
 
-                  (void) FormatMagickString(message,MaxTextExtent,
+                  (void) FormatLocaleString(message,MaxTextExtent,
                     "invalid %.60s value",attribute);
                   ThrowPerlException(exception,OptionError,message,
                     SvPV(ST(i),na));
@@ -13413,9 +13532,10 @@ SetPixel(ref,...)
         }
       }
     }
-    (void) SetImageStorageClass(image,DirectClass);
+    (void) SetImageStorageClass(image,DirectClass,exception);
+    channel_mask=SetPixelChannelMask(image,channel);
     q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
-    if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL) ||
+    if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
         (SvTYPE(av) != SVt_PVAV))
       PUSHs(&sv_undef);
     else
@@ -13427,43 +13547,47 @@ SetPixel(ref,...)
           i;
 
         i=0;
-        indexes=GetAuthenticIndexQueue(image);
         scale=1.0;
         if (normalize != MagickFalse)
           scale=QuantumRange;
-        if (((channel & RedChannel) != 0) && (i <= av_len(av)))
+        if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
+            (i <= av_len(av)))
           {
-            SetRedPixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
-              av_fetch(av,i,0)))));
+            SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
+              av_fetch(av,i,0)))),q);
             i++;
           }
-        if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
+        if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
+            (i <= av_len(av)))
           {
-            SetGreenPixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
-              av_fetch(av,i,0)))));
+            SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
+              av_fetch(av,i,0)))),q);
             i++;
           }
-        if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
+        if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
+            (i <= av_len(av)))
           {
-            SetBluePixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
-              av_fetch(av,i,0)))));
+            SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
+              av_fetch(av,i,0)))),q);
             i++;
           }
-        if ((((channel & IndexChannel) != 0) &&
+        if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
             (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
           {
-            SetIndexPixelComponent(indexes,ClampToQuantum(QuantumRange*
-              SvNV(*(av_fetch(av,i,0)))));
+            SetPixelBlack(image,ClampToQuantum(scale*
+              SvNV(*(av_fetch(av,i,0)))),q);
             i++;
           }
-        if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
+        if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
+            (i <= av_len(av)))
           {
-            SetOpacityPixelComponent(q,ClampToQuantum(QuantumRange*
-              SvNV(*(av_fetch(av,i,0)))));
+            SetPixelAlpha(image,ClampToQuantum(scale*
+              SvNV(*(av_fetch(av,i,0)))),q);
             i++;
           }
         (void) SyncAuthenticPixels(image,exception);
       }
+    (void) SetPixelChannelMask(image,channel_mask);
 
   PerlException:
     InheritPerlException(exception,perl_exception);
@@ -13647,25 +13771,25 @@ Statistics(ref,...)
   {
 #define ChannelStatistics(channel) \
 { \
-  (void) FormatMagickString(message,MaxTextExtent,"%.20g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
     (double) channel_statistics[channel].depth); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].minima/scale); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].maxima/scale); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].mean/scale); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].standard_deviation/scale); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].kurtosis); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
-  (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
+  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
     channel_statistics[channel].skewness); \
   PUSHs(sv_2mortal(newSVpv(message,0))); \
 }
@@ -13685,9 +13809,6 @@ Statistics(ref,...)
     ExceptionInfo
       *exception;
 
-    HV
-      *hv;
-
     Image
       *image;
 
@@ -13698,7 +13819,6 @@ Statistics(ref,...)
       *info;
 
     SV
-      *av_reference,
       *perl_exception,
       *reference;
 
@@ -13714,9 +13834,7 @@ Statistics(ref,...)
         goto PerlException;
       }
     reference=SvRV(ST(0));
-    hv=SvSTASH(reference);
     av=newAV();
-    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
     image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
     if (image == (Image *) NULL)
@@ -13729,7 +13847,7 @@ Statistics(ref,...)
     count=0;
     for ( ; image; image=image->next)
     {
-      channel_statistics=GetImageChannelStatistics(image,&image->exception);
+      channel_statistics=GetImageStatistics(image,exception);
       if (channel_statistics == (ChannelStatistics *) NULL)
         continue;
       count++;
@@ -13739,9 +13857,9 @@ Statistics(ref,...)
       ChannelStatistics(GreenChannel);
       ChannelStatistics(BlueChannel);
       if (image->colorspace == CMYKColorspace)
-        ChannelStatistics(IndexChannel);
+        ChannelStatistics(BlackChannel);
       if (image->matte != MagickFalse)
-        ChannelStatistics(OpacityChannel);
+        ChannelStatistics(AlphaChannel);
       channel_statistics=(ChannelStatistics *)
         RelinquishMagickMemory(channel_statistics);
     }
@@ -13812,7 +13930,6 @@ SyncAuthenticPixels(ref,...)
     status=SyncAuthenticPixels(image,exception);
     if (status != MagickFalse)
       return;
-    InheritException(exception,&image->exception);
 
   PerlException:
     InheritPerlException(exception,perl_exception);
@@ -13965,7 +14082,7 @@ Transform(ref,...)
       clone=CloneImage(image,0,0,MagickTrue,exception);
       if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
         goto PerlException;
-      TransformImage(&clone,crop_geometry,geometry);
+      TransformImage(&clone,crop_geometry,geometry,exception);
       for ( ; clone; clone=clone->next)
       {
         AddImageToRegistry(sv,clone);
@@ -14071,13 +14188,10 @@ Write(ref,...)
       next->scene=scene++;
     }
     SetImageInfo(package_info->image_info,(unsigned int)
-      GetImageListLength(image),&image->exception);
+      GetImageListLength(image),exception);
     for (next=image; next; next=next->next)
     {
-      (void) WriteImage(package_info->image_info,next);
-      if (next->exception.severity >= ErrorException)
-        InheritException(exception,&next->exception);
-      GetImageException(next,exception);
+      (void) WriteImage(package_info->image_info,next,exception);
       number_images++;
       if (package_info->image_info->adjoin)
         break;