]> granicus.if.org Git - imagemagick/blobdiff - Magick++/lib/Image.cpp
Added setColorMetric to Magick++.
[imagemagick] / Magick++ / lib / Image.cpp
index de6c83f1bb2f76f6453813a8f14706323c0e181a..b51e850302189187bb0adb31bd7cec2f2d954b85 100644 (file)
@@ -1,7 +1,7 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
-// Copyright Dirk Lemstra 2013-2014
+// Copyright Dirk Lemstra 2013-2015
 //
 // Implementation of Image
 //
@@ -27,6 +27,7 @@ using namespace std;
 #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
 #define MagickPI  3.14159265358979323846264338327950288419716939937510
 #define DegreesToRadians(x)  (MagickPI*(x)/180.0)
+#define ThrowImageException ThrowPPException(quiet())
 
 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
@@ -84,13 +85,11 @@ Magick::Image::Image(const Blob &blob_)
   try
   {
     // Initialize, Allocate and Read images
+    quiet(true);
     read(blob_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch (const Error &/*error_*/)
+  catch (const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -104,13 +103,11 @@ Magick::Image::Image(const Blob &blob_,const Geometry &size_)
   try
   {
     // Read from Blob
+    quiet(true);
     read(blob_, size_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -125,13 +122,11 @@ Magick::Image::Image(const Blob &blob_,const Geometry &size_,
   try
   {
     // Read from Blob
+    quiet(true);
     read(blob_,size_,depth_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -146,13 +141,11 @@ Magick::Image::Image(const Blob &blob_,const Geometry &size_,
   try
   {
     // Read from Blob
+    quiet(true);
     read(blob_,size_,depth_,magick_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -167,13 +160,11 @@ Magick::Image::Image(const Blob &blob_,const Geometry &size_,
   try
   {
     // Read from Blob
+    quiet(true);
     read(blob_,size_,magick_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -190,17 +181,15 @@ Magick::Image::Image(const Geometry &size_,const Color &color_)
 
   try
   {
+    quiet(true);
     // Set image size
     size(size_);
 
     // Initialize, Allocate and Read images
     read(imageSpec);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error & /*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -214,19 +203,41 @@ Magick::Image::Image(const Image &image_)
   _imgRef->increase();
 }
 
+Magick::Image::Image(const Image &image_,const Geometry &geometry_)
+  : _imgRef(new ImageRef)
+{
+  const RectangleInfo
+    geometry=geometry_;
+
+  OffsetInfo
+    offset;
+
+  MagickCore::Image
+    *image;
+
+  GetPPException;
+  image=CloneImage(image_.constImage(),geometry_.width(),geometry_.height(),
+    MagickTrue,exceptionInfo);
+  replaceImage(image);
+  _imgRef->options(new Options(*image_.constOptions()));
+  offset.x=0;
+  offset.y=0;
+  (void) CopyImagePixels(image,image_.constImage(),&geometry,&offset,
+    exceptionInfo);
+  ThrowImageException;
+}
+
 Magick::Image::Image(const size_t width_,const size_t height_,
   const std::string &map_,const StorageType type_,const void *pixels_)
   : _imgRef(new ImageRef)
 {
   try
   {
+    quiet(true);
     read(width_,height_,map_.c_str(),type_,pixels_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -240,13 +251,11 @@ Magick::Image::Image(const std::string &imageSpec_)
   try
   {
     // Initialize, Allocate and Read images
+    quiet(true);
     read(imageSpec_);
+    quiet(false);
   }
-  catch(const Warning &/*warning_*/)
-  {
-    // FIXME: need a way to report warnings in constructor
-  }
-  catch(const Error &/*error_*/)
+  catch(const Error&)
   {
     // Release resources
     delete _imgRef;
@@ -299,7 +308,7 @@ void Magick::Image::alpha(const bool matteFlag_)
   if ((matteFlag_ && !constImage()->alpha_trait) ||
       (constImage()->alpha_trait && !matteFlag_))
     SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   image()->alpha_trait=matteFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
 }
@@ -335,17 +344,6 @@ Magick::Color Magick::Image::alphaColor(void) const
   return(Color(constImage()->matte_color));
 }
 
-void Magick::Image::antiAlias(const bool flag_)
-{
-  modifyImage();
-  options()->antiAlias(static_cast<size_t>(flag_));
-}
-
-bool Magick::Image::antiAlias(void)
-{
-  return(static_cast<bool>(options()->antiAlias()));
-}
-
 void Magick::Image::animationDelay(const size_t delay_)
 {
   modifyImage();
@@ -371,10 +369,10 @@ size_t Magick::Image::animationIterations(void) const
 void Magick::Image::attenuate(const double attenuate_)
 {
   char
-    value[MaxTextExtent];
+    value[MagickPathExtent];
 
   modifyImage();
-  FormatLocaleString(value,MaxTextExtent,"%.20g",attenuate_);
+  FormatLocaleString(value,MagickPathExtent,"%.20g",attenuate_);
   (void) SetImageArtifact(image(),"attenuate",value);
 }
 
@@ -455,7 +453,7 @@ Magick::Geometry Magick::Image::boundingBox(void) const
 
   GetPPException;
   bbox=GetImageBoundingBox(constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   return(Geometry(bbox));
 }
 
@@ -475,10 +473,10 @@ void Magick::Image::channelDepth(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   SetImageDepth(image(),depth_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 size_t Magick::Image::channelDepth(const ChannelType channel_)
@@ -487,10 +485,10 @@ size_t Magick::Image::channelDepth(const ChannelType channel_)
     channel_depth;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   channel_depth=GetImageDepth(constImage(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
   return(channel_depth);
 }
 
@@ -508,7 +506,7 @@ void Magick::Image::classType(const ClassType class_)
       modifyImage();
       GetPPException;
       SyncImage(image(),exceptionInfo);
-      ThrowPPException;
+      ThrowImageException;
       image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
       image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
       return;
@@ -544,19 +542,20 @@ double Magick::Image::colorFuzz(void) const
 void Magick::Image::colorMapSize(const size_t entries_)
 {
   if (entries_ >MaxColormapSize)
-    throwExceptionExplicit(OptionError,
+    throwExceptionExplicit(MagickCore::OptionError,
       "Colormap entries must not exceed MaxColormapSize");
 
   modifyImage();
   GetPPException;
   (void) AcquireImageColormap(image(),entries_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 size_t Magick::Image::colorMapSize(void) const
 {
   if (!constImage()->colormap)
-    throwExceptionExplicit(OptionError,"Image does not contain a colormap");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Image does not contain a colormap");
 
   return(constImage()->colors);
 }
@@ -569,7 +568,7 @@ void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
   modifyImage();
   GetPPException;
   TransformImageColorspace(image(),colorSpace_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 Magick::ColorspaceType Magick::Image::colorSpace(void) const
@@ -582,7 +581,7 @@ void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
   modifyImage();
   GetPPException;
   SetImageColorspace(image(),colorSpace_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   options()->colorspaceType(colorSpace_);
 }
 
@@ -603,7 +602,7 @@ void Magick::Image::comment(const std::string &comment_)
   SetImageProperty(image(),"Comment",NULL,exceptionInfo);
   if (comment_.length() > 0)
     SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 std::string Magick::Image::comment(void) const
@@ -613,7 +612,7 @@ std::string Magick::Image::comment(void) const
 
   GetPPException;
   value=GetImageProperty(constImage(),"Comment",exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   if (value)
     return(std::string(value));
@@ -717,8 +716,9 @@ std::string Magick::Image::directory(void) const
   if (constImage()->directory)
     return(std::string(constImage()->directory));
 
-  throwExceptionExplicit(CorruptImageWarning,
-    "Image does not contain a directory");
+  if (!quiet())
+    throwExceptionExplicit(MagickCore::CorruptImageWarning,
+      "Image does not contain a directory");
 
   return(std::string());
 }
@@ -749,7 +749,7 @@ void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
       GetPPException;
       (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
       exif_profile=DestroyStringInfo(exif_profile);
-      ThrowPPException;
+      ThrowImageException;
     }
 }
 
@@ -787,13 +787,8 @@ MagickCore::MagickSizeType Magick::Image::fileSize(void) const
 
 void Magick::Image::fillColor(const Magick::Color &fillColor_)
 {
-  std::string
-    value;
-
   modifyImage();
   options()->fillColor(fillColor_);
-  value=fillColor_;
-  artifact("fill",value);
 }
 
 Magick::Color Magick::Image::fillColor(void) const
@@ -840,7 +835,7 @@ Magick::Image Magick::Image::fillPattern(void) const
       GetPPException;
       image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
       texture.replaceImage(image);
-      ThrowPPException;
+      ThrowImageException;
     }
   return(texture);
 }
@@ -867,6 +862,17 @@ std::string Magick::Image::font(void) const
   return(constOptions()->font());
 }
 
+void Magick::Image::fontFamily(const std::string &family_)
+{
+  modifyImage();
+  options()->fontFamily(family_);
+}
+
+std::string Magick::Image::fontFamily(void) const
+{
+  return(constOptions()->fontFamily());
+}
+
 void Magick::Image::fontPointsize(const double pointSize_)
 {
   modifyImage();
@@ -878,6 +884,28 @@ double Magick::Image::fontPointsize(void) const
   return(constOptions()->fontPointsize());
 }
 
+void Magick::Image::fontStyle(const StyleType pointSize_)
+{
+  modifyImage();
+  options()->fontStyle(pointSize_);
+}
+
+Magick::StyleType Magick::Image::fontStyle(void) const
+{
+  return(constOptions()->fontStyle());
+}
+
+void Magick::Image::fontWeight(const size_t weight_)
+{
+  modifyImage();
+  options()->fontWeight(weight_);
+}
+
+size_t Magick::Image::fontWeight(void) const
+{
+  return(constOptions()->fontWeight());
+}
+
 std::string Magick::Image::format(void) const
 {
   const MagickInfo 
@@ -885,12 +913,15 @@ std::string Magick::Image::format(void) const
 
   GetPPException;
   magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   if ((magick_info != 0) && (*magick_info->description != '\0'))
     return(std::string(magick_info->description));
 
-  throwExceptionExplicit(CorruptImageWarning,"Unrecognized image magick type");
+  if (!quiet())
+    throwExceptionExplicit(MagickCore::CorruptImageWarning,
+      "Unrecognized image magick type");
+
   return(std::string());
 }
 
@@ -911,7 +942,7 @@ std::string Magick::Image::formatExpression(const std::string expression)
       text_string=std::string(text);
       text=DestroyString(text);
     }
-  ThrowPPException;
+  ThrowImageException;
   return(text_string);
 }
 
@@ -925,7 +956,9 @@ Magick::Geometry Magick::Image::geometry(void) const
   if (constImage()->geometry)
     return Geometry(constImage()->geometry);
 
-  throwExceptionExplicit(OptionWarning,"Image does not contain a geometry");
+  if (!quiet())
+    throwExceptionExplicit(MagickCore::OptionWarning,
+      "Image does not contain a geometry");
 
   return(Geometry());
 }
@@ -942,6 +975,17 @@ MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
   return(constImage()->dispose);
 }
 
+bool Magick::Image::hasChannel(const PixelChannel channel) const
+{
+  if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
+    return(false);
+
+  if (channel == GreenPixelChannel || channel == BluePixelChannel)
+    return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
+
+  return(true);
+}
+
 void Magick::Image::highlightColor(const Color color_)
 {
   std::string
@@ -953,7 +997,7 @@ void Magick::Image::highlightColor(const Color color_)
 
 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
 {
-  profile("icm",colorProfile_);
+  profile("icc",colorProfile_);
 }
 
 Magick::Blob Magick::Image::iccColorProfile(void) const
@@ -1004,7 +1048,7 @@ void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
       GetPPException;
       (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
       iptc_profile=DestroyStringInfo(iptc_profile);
-      ThrowPPException;
+      ThrowImageException;
     }
 }
 
@@ -1020,6 +1064,17 @@ Magick::Blob Magick::Image::iptcProfile(void) const
     iptc_profile)));
 }
 
+bool Magick::Image::isOpaque(void) const
+{
+  MagickBooleanType
+    result;
+
+  GetPPException;
+  result=IsImageOpaque(constImage(),exceptionInfo);
+  ThrowImageException;
+  return(result != MagickFalse ? true : false);
+}
+
 void Magick::Image::isValid(const bool isValid_)
 {
   if (!isValid_)
@@ -1048,7 +1103,7 @@ void Magick::Image::label(const std::string &label_)
   (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
   if (label_.length() > 0)
     (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 std::string Magick::Image::label(void) const
@@ -1058,7 +1113,7 @@ std::string Magick::Image::label(void) const
 
   GetPPException;
   value=GetImageProperty(constImage(),"Label",exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   if (value)
     return(std::string(value));
@@ -1081,10 +1136,11 @@ void Magick::Image::mask(const Magick::Image &mask_)
 
   GetPPException;
   if (mask_.isValid())
-    SetImageMask(image(),mask_.constImage(),exceptionInfo);
+    SetImageMask(image(),ReadPixelMask,mask_.constImage(),exceptionInfo);
   else
-    SetImageMask(image(),(MagickCore::Image *) NULL,exceptionInfo);
-  ThrowPPException;
+    SetImageMask(image(),ReadPixelMask,(MagickCore::Image *) NULL,
+      exceptionInfo);
+  ThrowImageException;
 }
 
 Magick::Image Magick::Image::mask(void) const
@@ -1094,7 +1150,7 @@ Magick::Image Magick::Image::mask(void) const
 
   GetPPException;
   image=GetImageMask(constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   if (image == (MagickCore::Image *) NULL)
     return(Magick::Image());
@@ -1104,11 +1160,19 @@ Magick::Image Magick::Image::mask(void) const
 
 void Magick::Image::magick(const std::string &magick_)
 {
+  size_t
+    length;
+
   modifyImage();
 
-  magick_.copy(image()->magick,sizeof(image()->magick)-1);
-  image()->magick[magick_.length()]=0;
-  
+  length=sizeof(image()->magick)-1;
+  if (magick_.length() < length)
+    length=magick_.length();
+
+  if (!magick_.empty())
+    magick_.copy(image()->magick,length);
+  image()->magick[length]=0;
+
   options()->magick(magick_);
 }
 
@@ -1130,7 +1194,7 @@ void Magick::Image::modulusDepth(const size_t depth_)
   modifyImage();
   GetPPException;
   SetImageDepth(image(),depth_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   options()->depth(depth_);
 }
 
@@ -1141,7 +1205,7 @@ size_t Magick::Image::modulusDepth(void) const
 
   GetPPException;
   depth=GetImageDepth(constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   return(depth);
 }
 
@@ -1161,7 +1225,8 @@ Magick::Geometry Magick::Image::montageGeometry(void) const
   if (constImage()->montage)
     return Magick::Geometry(constImage()->montage);
 
-  throwExceptionExplicit(CorruptImageWarning,
+  if (!quiet())
+    throwExceptionExplicit(MagickCore::CorruptImageWarning,
     "Image does not contain a montage");
 
   return(Magick::Geometry());
@@ -1198,7 +1263,7 @@ void Magick::Image::page(const Magick::Geometry &pageSize_)
 Magick::Geometry Magick::Image::page(void) const
 {
   return(Geometry(constImage()->page.width,constImage()->page.height,
-    AbsoluteValue(constImage()->page.x),AbsoluteValue(constImage()->page.y)));
+    constImage()->page.x,constImage()->page.y));
 }
 
 void Magick::Image::quality(const size_t quality_)
@@ -1269,6 +1334,17 @@ size_t Magick::Image::quantizeTreeDepth() const
   return(constOptions()->quantizeTreeDepth());
 }
 
+void Magick::Image::quiet(const bool quiet_)
+{
+  modifyImage();
+  options()->quiet(quiet_);
+}
+
+bool Magick::Image::quiet(void) const
+{
+  return(constOptions()->quiet());
+}
+
 void Magick::Image::renderingIntent(
   const Magick::RenderingIntent renderingIntent_)
 {
@@ -1433,7 +1509,7 @@ Magick::Image Magick::Image::strokePattern(void) const
       GetPPException;
       image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
       texture.replaceImage(image);
-      ThrowPPException;
+      ThrowImageException;
     }
   return(texture);
 }
@@ -1441,11 +1517,11 @@ Magick::Image Magick::Image::strokePattern(void) const
 void Magick::Image::strokeWidth(const double strokeWidth_)
 {
   char
-    value[MaxTextExtent];
+    value[MagickPathExtent];
 
   modifyImage();
   options()->strokeWidth(strokeWidth_);
-  FormatLocaleString(value,MaxTextExtent,"%.20g",strokeWidth_);
+  FormatLocaleString(value,MagickPathExtent,"%.20g",strokeWidth_);
   (void) SetImageArtifact(image(),"strokewidth",value);
 }
 
@@ -1476,6 +1552,17 @@ size_t Magick::Image::subRange(void) const
   return(constOptions()->subRange());
 }
 
+void Magick::Image::textAntiAlias(const bool flag_)
+{
+  modifyImage();
+  options()->textAntiAlias(flag_);
+}
+
+bool Magick::Image::textAntiAlias(void) const
+{
+  return(constOptions()->textAntiAlias());
+}
+
 void Magick::Image::textDirection(DirectionType direction_)
 {
   modifyImage();
@@ -1542,14 +1629,25 @@ double Magick::Image::textKerning(void) const
   return(constOptions()->textKerning());
 }
 
+void Magick::Image::textUnderColor(const Color &underColor_)
+{
+  modifyImage();
+  options()->textUnderColor(underColor_);
+}
+
+Magick::Color Magick::Image::textUnderColor(void) const
+{
+  return(constOptions()->textUnderColor());
+}
+
 size_t Magick::Image::totalColors(void) const
 {
   size_t
     colors;
 
   GetPPException;
-  colors=GetNumberColors(constImage(),0,exceptionInfo);
-  ThrowPPException;
+  colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
+  ThrowImageException;
   return colors;
 }
 
@@ -1575,10 +1673,7 @@ Magick::ImageType Magick::Image::type(void) const
 {
   if (constOptions()->type() != UndefinedType)
     return(constOptions()->type());
-  else if (constImage()->type != UndefinedType)
-    return(constImage()->type);
-  else
-    return(determineType());
+  return(GetImageType(constImage()));
 }
 
 void Magick::Image::type(const Magick::ImageType type_)
@@ -1587,7 +1682,7 @@ void Magick::Image::type(const Magick::ImageType type_)
   options()->type(type_);
   GetPPException;
   SetImageType(image(),type_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::verbose(const bool verboseFlag_)
@@ -1618,7 +1713,7 @@ void Magick::Image::virtualPixelMethod(
   modifyImage();
   GetPPException;
   SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
@@ -1655,7 +1750,7 @@ void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
   GetPPException;
   newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::adaptiveResize(const Geometry &geometry_)
@@ -1677,7 +1772,7 @@ void Magick::Image::adaptiveResize(const Geometry &geometry_)
   GetPPException;
   newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
@@ -1688,7 +1783,7 @@ void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
   GetPPException;
   newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
@@ -1698,25 +1793,25 @@ void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
-  const ssize_t offset_)
+   const double bias_)
 {
 
   MagickCore::Image
     *newImage;
 
   GetPPException;
-  newImage=AdaptiveThresholdImage(constImage(),width_,height_,offset_,
+  newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::addNoise(const NoiseType noiseType_)
@@ -1727,7 +1822,7 @@ void Magick::Image::addNoise(const NoiseType noiseType_)
   GetPPException;
   newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::addNoiseChannel(const ChannelType channel_,
@@ -1737,11 +1832,11 @@ void Magick::Image::addNoiseChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=AddNoiseImage(constImage(),noiseType_,1.0,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::affineTransform(const DrawableAffine &affine_)
@@ -1762,7 +1857,7 @@ void Magick::Image::affineTransform(const DrawableAffine &affine_)
   GetPPException;
   newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::alpha(const unsigned int alpha_)
@@ -1770,7 +1865,7 @@ void Magick::Image::alpha(const unsigned int alpha_)
   modifyImage();
   GetPPException;
   SetImageAlpha(image(),alpha_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
@@ -1778,7 +1873,7 @@ void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
   modifyImage();
   GetPPException;
   SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::annotate(const std::string &text_,
@@ -1801,7 +1896,7 @@ void Magick::Image::annotate(const std::string &text_,
     oaffine;
 
   char
-    boundingArea[MaxTextExtent];
+    boundingArea[MagickPathExtent];
 
   DrawInfo
     *drawInfo;
@@ -1816,13 +1911,13 @@ void Magick::Image::annotate(const std::string &text_,
     {
       if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
         {
-          FormatLocaleString(boundingArea,MaxTextExtent,"%+.20g%+.20g",
+          FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
             (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
         }
       else
         {
-          (void) CopyMagickString(boundingArea,string(boundingArea_).c_str(),
-            MaxTextExtent);
+          (void) CopyMagickString(boundingArea,
+            std::string(boundingArea_).c_str(), MagickPathExtent);
         }
       drawInfo->geometry=boundingArea;
     }
@@ -1865,7 +1960,7 @@ void Magick::Image::annotate(const std::string &text_,
   drawInfo->text=0;
   drawInfo->geometry=0;
 
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::annotate(const std::string &text_,
@@ -1886,7 +1981,7 @@ void Magick::Image::annotate(const std::string &text_,
   drawInfo->gravity=NorthWestGravity;
   drawInfo->text=0;
 
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::artifact(const std::string &name_,const std::string &value_)
@@ -1895,7 +1990,7 @@ void Magick::Image::artifact(const std::string &name_,const std::string &value_)
   (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
 }
 
-std::string Magick::Image::artifact(const std::string &name_)
+std::string Magick::Image::artifact(const std::string &name_) const
 {
   const char
     *value;
@@ -1911,17 +2006,17 @@ void Magick::Image::attribute(const std::string name_,const std::string value_)
   modifyImage();
   GetPPException;
   SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-std::string Magick::Image::attribute(const std::string name_)
+std::string Magick::Image::attribute(const std::string name_) const
 {
   const char
     *value;
 
   GetPPException;
   value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 
   if (value)
     return(std::string(value));
@@ -1935,38 +2030,36 @@ void Magick::Image::autoGamma(void)
   GetPPException;
   (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
   (void) AutoGammaImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::autoGammaChannel(const ChannelType channel_)
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
   (void) AutoGammaImage(image(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::autoLevel(void)
 {
   modifyImage();
   GetPPException;
-  (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
   (void) AutoLevelImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::autoLevelChannel(const ChannelType channel_)
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
-  (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
+  GetAndSetPPChannelMask(channel_);
   (void) AutoLevelImage(image(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::autoOrient(void)
@@ -1979,10 +2072,9 @@ void Magick::Image::autoOrient(void)
     return;
 
   GetPPException;
-  (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
   newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::blackThreshold(const std::string &threshold_)
@@ -1990,7 +2082,7 @@ void Magick::Image::blackThreshold(const std::string &threshold_)
   modifyImage();
   GetPPException;
   BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::blackThresholdChannel(const ChannelType channel_,
@@ -1998,10 +2090,10 @@ void Magick::Image::blackThresholdChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::blueShift(const double factor_)
@@ -2012,7 +2104,7 @@ void Magick::Image::blueShift(const double factor_)
   GetPPException;
   newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::blur(const double radius_,const double sigma_)
@@ -2023,7 +2115,7 @@ void Magick::Image::blur(const double radius_,const double sigma_)
   GetPPException;
   newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::blurChannel(const ChannelType channel_,
@@ -2033,11 +2125,11 @@ void Magick::Image::blurChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::border(const Geometry &geometry_)
@@ -2052,7 +2144,7 @@ void Magick::Image::border(const Geometry &geometry_)
   newImage=BorderImage(constImage(),&borderInfo,image()->compose,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::brightnessContrast(const double brightness_,
@@ -2061,7 +2153,7 @@ void Magick::Image::brightnessContrast(const double brightness_,
   modifyImage();
   GetPPException;
   BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
@@ -2069,10 +2161,10 @@ void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::cannyEdge(const double radius_,const double sigma_,
@@ -2086,7 +2178,15 @@ void Magick::Image::cannyEdge(const double radius_,const double sigma_,
   newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
     upperPercent_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::cdl(const std::string &cdl_)
+{
+  modifyImage();
+  GetPPException;
+  (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
+  ThrowImageException;
 }
 
 void Magick::Image::channel(const ChannelType channel_)
@@ -2097,7 +2197,7 @@ void Magick::Image::channel(const ChannelType channel_)
   GetPPException;
   newImage=SeparateImage(image(),channel_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::charcoal(const double radius_,const double sigma_)
@@ -2108,7 +2208,7 @@ void Magick::Image::charcoal(const double radius_,const double sigma_)
   GetPPException;
   newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::chop(const Geometry &geometry_)
@@ -2122,7 +2222,7 @@ void Magick::Image::chop(const Geometry &geometry_)
   GetPPException;
   newImage=ChopImage(image(),&chopInfo,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::chromaBluePrimary(const double x_,const double y_)
@@ -2177,30 +2277,22 @@ void Magick::Image::chromaWhitePoint(double *x_,double *y_) const
   *y_=constImage()->chromaticity.white_point.y;
 }
 
-void Magick::Image::cdl(const std::string &cdl_)
-{
-  modifyImage();
-  GetPPException;
-  (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
-  ThrowPPException;
-}
-
 void Magick::Image::clamp(void)
 {
   modifyImage();
   GetPPException;
   ClampImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::clampChannel(const ChannelType channel_)
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   ClampImage(image(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::clip(void)
@@ -2208,7 +2300,7 @@ void Magick::Image::clip(void)
   modifyImage();
   GetPPException;
   ClipImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
@@ -2217,7 +2309,7 @@ void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
   GetPPException;
   ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::clut(const Image &clutImage_,
@@ -2226,7 +2318,7 @@ void Magick::Image::clut(const Image &clutImage_,
   modifyImage();
   GetPPException;
   ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::clutChannel(const ChannelType channel_,
@@ -2234,10 +2326,10 @@ void Magick::Image::clutChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
@@ -2250,7 +2342,7 @@ void Magick::Image::colorize(const unsigned int alphaRed_,
   const Color &penColor_)
 {
   char
-    blend[MaxTextExtent];
+    blend[MagickPathExtent];
 
   MagickCore::Image
     *newImage;
@@ -2259,16 +2351,17 @@ void Magick::Image::colorize(const unsigned int alphaRed_,
     target;
 
   if (!penColor_.isValid())
-    throwExceptionExplicit(OptionError,"Pen color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Pen color argument is invalid");
 
-  FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
+  FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
     alphaBlue_);
 
   target=static_cast<PixelInfo>(penColor_);
   GetPPException;
   newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::colorMap(const size_t index_,const Color &color_)
@@ -2279,11 +2372,12 @@ void Magick::Image::colorMap(const size_t index_,const Color &color_)
   imageptr=image();
 
   if (index_ > (MaxColormapSize-1))
-    throwExceptionExplicit(OptionError,
+    throwExceptionExplicit(MagickCore::OptionError,
       "Colormap index must be less than MaxColormapSize");
 
   if (!color_.isValid())
-    throwExceptionExplicit(OptionError,"Color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Color argument is invalid");
 
   modifyImage();
 
@@ -2299,12 +2393,13 @@ Magick::Color Magick::Image::colorMap(const size_t index_) const
 {
   if (!constImage()->colormap)
     {
-      throwExceptionExplicit(OptionError,"Image does not contain a colormap");
+      throwExceptionExplicit(MagickCore::OptionError,
+        "Image does not contain a colormap");
       return(Color());
     }
 
   if (index_ > constImage()->colors-1)
-    throwExceptionExplicit(OptionError,"Index out of range");
+    throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
 
   return(Magick::Color((constImage()->colormap)[index_]));
 }
@@ -2335,10 +2430,10 @@ void Magick::Image::colorMatrix(const size_t order_,
         }
       kernel_info=DestroyKernelInfo(kernel_info);
     }
-  ThrowPPException;
+  ThrowImageException;
 }
 
-bool Magick::Image::compare(const Image &reference_)
+bool Magick::Image::compare(const Image &reference_) const
 {
   bool
     status;
@@ -2347,10 +2442,9 @@ bool Magick::Image::compare(const Image &reference_)
     ref=reference_;
 
   GetPPException;
-  modifyImage();
-  ref.modifyImage();
-  status=static_cast<bool>(IsImagesEqual(image(),ref.image(),exceptionInfo));
-  ThrowPPException;
+  status=static_cast<bool>(IsImagesEqual(constImage(),ref.constImage(),
+    exceptionInfo));
+  ThrowImageException;
   return(status);
 }
 
@@ -2362,7 +2456,7 @@ double Magick::Image::compare(const Image &reference_,const MetricType metric_)
   GetPPException;
   GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   return(distortion);
 }
 
@@ -2373,11 +2467,11 @@ double Magick::Image::compareChannel(const ChannelType channel_,
     distortion=0.0;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
     exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
   return(distortion);
 }
 
@@ -2390,7 +2484,7 @@ Magick::Image Magick::Image::compare(const Image &reference_,
   GetPPException;
   newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   if (newImage == (MagickCore::Image *) NULL)
     return(Magick::Image());
   else
@@ -2404,11 +2498,11 @@ Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
     exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
   if (newImage == (MagickCore::Image *) NULL)
     return(Magick::Image());
   else
@@ -2433,7 +2527,7 @@ void Magick::Image::composite(const Image &compositeImage_,
   GetPPException;
   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
     x,y,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::composite(const Image &compositeImage_,
@@ -2449,7 +2543,7 @@ void Magick::Image::composite(const Image &compositeImage_,
   GetPPException;
   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
     geometry.x,geometry.y,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::composite(const Image &compositeImage_,
@@ -2462,7 +2556,7 @@ void Magick::Image::composite(const Image &compositeImage_,
   GetPPException;
   CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
     xOffset_,yOffset_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::connectedComponents(const size_t connectivity_)
@@ -2473,15 +2567,15 @@ void Magick::Image::connectedComponents(const size_t connectivity_)
   GetPPException;
   newImage=ConnectedComponentsImage(constImage(),connectivity_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-void Magick::Image::contrast(const size_t sharpen_)
+void Magick::Image::contrast(const bool sharpen_)
 {
   modifyImage();
   GetPPException;
   ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::contrastStretch(const double blackPoint_,
@@ -2490,7 +2584,7 @@ void Magick::Image::contrastStretch(const double blackPoint_,
   modifyImage();
   GetPPException;
   ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::contrastStretchChannel(const ChannelType channel_,
@@ -2498,10 +2592,10 @@ void Magick::Image::contrastStretchChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::convolve(const size_t order_,const double *kernel_)
@@ -2526,7 +2620,22 @@ void Magick::Image::convolve(const size_t order_,const double *kernel_)
       replaceImage(newImage);
     }
   kernel_info=DestroyKernelInfo(kernel_info);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
+  const Offset &offset_)
+{
+  const OffsetInfo
+    offset=offset_;
+
+  const RectangleInfo
+    geometry=geometry_;
+
+  GetPPException;
+  (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
+    exceptionInfo);
+  ThrowImageException;
 }
 
 void Magick::Image::crop(const Geometry &geometry_)
@@ -2540,7 +2649,7 @@ void Magick::Image::crop(const Geometry &geometry_)
   GetPPException;
   newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::cycleColormap(const ssize_t amount_)
@@ -2548,7 +2657,7 @@ void Magick::Image::cycleColormap(const ssize_t amount_)
   modifyImage();
   GetPPException;
   CycleColormapImage(image(),amount_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::decipher(const std::string &passphrase_)
@@ -2556,7 +2665,7 @@ void Magick::Image::decipher(const std::string &passphrase_)
   modifyImage();
   GetPPException;
   DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::defineSet(const std::string &magick_,
@@ -2626,7 +2735,7 @@ void Magick::Image::deskew(const double threshold_)
   GetPPException;
   newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::despeckle(void)
@@ -2637,25 +2746,14 @@ void Magick::Image::despeckle(void)
   GetPPException;
   newImage=DespeckleImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
-}
-
-Magick::ImageType Magick::Image::determineType(void) const
-{
-  ImageType
-    image_type;
-
-  GetPPException;
-  image_type=GetImageType(constImage(),exceptionInfo);
-  ThrowPPException;
-  return(image_type);
+  ThrowImageException;
 }
 
 void Magick::Image::display(void)
 {
   GetPPException;
   DisplayImages(imageInfo(),image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::distort(const DistortImageMethod method_,
@@ -2668,7 +2766,7 @@ void Magick::Image::distort(const DistortImageMethod method_,
   newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
     bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::draw(const Magick::Drawable &drawable_)
@@ -2688,7 +2786,7 @@ void Magick::Image::draw(const Magick::Drawable &drawable_)
 
       ClonePPDrawException(wand);
       wand=DestroyDrawingWand(wand);
-      ThrowPPDrawException;
+      ThrowPPDrawException(quiet());
     }
 }
 
@@ -2707,16 +2805,16 @@ void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
            p != drawable_.end(); p++ )
         {
           p->operator()(wand);
-          if (DrawGetExceptionType(wand) != UndefinedException)
+          if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
             break;
         }
 
-      if (DrawGetExceptionType(wand) == UndefinedException)
+      if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
         DrawRender(wand);
 
       ClonePPDrawException(wand);
       wand=DestroyDrawingWand(wand);
-      ThrowPPDrawException;
+      ThrowPPDrawException(quiet());
     }
 }
 
@@ -2728,7 +2826,7 @@ void Magick::Image::edge(const double radius_)
   GetPPException;
   newImage=EdgeImage(constImage(),radius_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::emboss(const double radius_,const double sigma_)
@@ -2739,7 +2837,7 @@ void Magick::Image::emboss(const double radius_,const double sigma_)
   GetPPException;
   newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::encipher(const std::string &passphrase_)
@@ -2747,7 +2845,7 @@ void Magick::Image::encipher(const std::string &passphrase_)
   modifyImage();
   GetPPException;
   EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::enhance(void)
@@ -2758,7 +2856,7 @@ void Magick::Image::enhance(void)
   GetPPException;
   newImage=EnhanceImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::equalize(void)
@@ -2766,7 +2864,7 @@ void Magick::Image::equalize(void)
   modifyImage();
   GetPPException;
   EqualizeImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::erase(void)
@@ -2774,7 +2872,56 @@ void Magick::Image::erase(void)
   modifyImage();
   GetPPException;
   (void) SetImageBackgroundColor(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,
+  const MagickEvaluateOperator operator_,double rvalue_)
+{
+  GetPPException;
+  GetAndSetPPChannelMask(channel_);
+  EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
+  RestorePPChannelMask;
+  ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,
+  const MagickFunction function_,const size_t number_parameters_,
+  const double *parameters_)
+{
+  GetPPException;
+  GetAndSetPPChannelMask(channel_);
+  FunctionImage(image(),function_,number_parameters_,parameters_,
+    exceptionInfo);
+  RestorePPChannelMask;
+  ThrowImageException;
+}
+
+void Magick::Image::evaluate(const ChannelType channel_,const ssize_t x_,
+  const ssize_t y_,const size_t columns_,const size_t rows_,
+  const MagickEvaluateOperator operator_,const double rvalue_)
+{
+  RectangleInfo
+    geometry;
+
+  MagickCore::Image
+    *cropImage;
+
+  geometry.width = columns_;
+  geometry.height = rows_;
+  geometry.x = x_;
+  geometry.y = y_;
+
+  GetPPException;
+  cropImage=CropImage(image(),&geometry,exceptionInfo);
+  GetAndSetPPChannelMask(channel_);
+  EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
+  RestorePPChannelMask;
+  (void) CompositeImage(image(),cropImage,image()->alpha_trait == 
+    BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
+    geometry.x,geometry.y,exceptionInfo );
+  cropImage=DestroyImageList(cropImage);
+  ThrowImageException;
 }
 
 void Magick::Image::extent(const Geometry &geometry_ )
@@ -2791,7 +2938,7 @@ void Magick::Image::extent(const Geometry &geometry_ )
   GetPPException;
   newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::extent(const Geometry &geometry_,
@@ -2829,7 +2976,7 @@ void Magick::Image::flip(void)
   GetPPException;
   newImage=FlipImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
@@ -2843,11 +2990,11 @@ void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
   target=static_cast<PixelInfo>(pixelColor(x_,y_));
   target.alpha=alpha_;
   GetPPException;
-  SetPPChannelMask(AlphaChannel);
+  GetAndSetPPChannelMask(AlphaChannel);
   FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
     (MagickBooleanType)invert_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
@@ -2861,11 +3008,11 @@ void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
   target=static_cast<PixelInfo>(target_);
   target.alpha=alpha_;
   GetPPException;
-  SetPPChannelMask(AlphaChannel);
+  GetAndSetPPChannelMask(AlphaChannel);
   FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
     (MagickBooleanType)invert_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::floodFillColor(const Geometry &point_,
@@ -2952,7 +3099,7 @@ void Magick::Image::flop(void)
   GetPPException;
   newImage=FlopImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::fontTypeMetrics(const std::string &text_,
@@ -2966,7 +3113,7 @@ void Magick::Image::fontTypeMetrics(const std::string &text_,
   GetPPException;
   GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
   drawInfo->text=0;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
@@ -2980,7 +3127,7 @@ void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
   GetPPException;
   GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
   drawInfo->text=0;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::frame(const Geometry &geometry_)
@@ -3001,11 +3148,11 @@ void Magick::Image::frame(const Geometry &geometry_)
   GetPPException;
   newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::frame(const size_t width_,const size_t height_,
-  const ssize_t outerBevel_,const ssize_t innerBevel_)
+  const ssize_t innerBevel_,const ssize_t outerBevel_)
 {
   FrameInfo
     info;
@@ -3023,7 +3170,7 @@ void Magick::Image::frame(const size_t width_,const size_t height_,
   GetPPException;
   newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::fx(const std::string expression_)
@@ -3034,7 +3181,7 @@ void Magick::Image::fx(const std::string expression_)
   GetPPException;
   newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::fx(const std::string expression_,
@@ -3044,11 +3191,11 @@ void Magick::Image::fx(const std::string expression_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::gamma(const double gamma_)
@@ -3056,22 +3203,22 @@ void Magick::Image::gamma(const double gamma_)
   modifyImage();
   GetPPException;
   GammaImage(image(),gamma_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
   const double gammaBlue_)
 {
-  char
-    gamma[MaxTextExtent + 1];
-
-  FormatLocaleString(gamma,MaxTextExtent,"%3.6f/%3.6f/%3.6f/",gammaRed_,
-    gammaGreen_,gammaBlue_);
-
   modifyImage();
   GetPPException;
-  GammaImage(image(),atof(gamma),exceptionInfo);
-  ThrowPPException;
+  GetAndSetPPChannelMask(RedChannel);
+  (void) GammaImage(image(),gammaRed_,exceptionInfo);
+  SetPPChannelMask(GreenChannel);
+  (void) GammaImage(image(),gammaGreen_,exceptionInfo);
+  SetPPChannelMask(BlueChannel);
+  (void) GammaImage(image(),gammaBlue_,exceptionInfo);
+  RestorePPChannelMask;
+  ThrowImageException;
 }
 
 void Magick::Image::gaussianBlur(const double width_,const double sigma_)
@@ -3082,7 +3229,7 @@ void Magick::Image::gaussianBlur(const double width_,const double sigma_)
   GetPPException;
   newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
@@ -3092,11 +3239,11 @@ void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=GaussianBlurImage(constImage(),width_,sigma_,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
@@ -3106,8 +3253,8 @@ const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
     *p;
 
   GetPPException;
-  p=(*GetVirtualPixels)(constImage(),x_, y_,columns_, rows_,exceptionInfo);
-  ThrowPPException;
+  p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
+  ThrowImageException;
   return(p);
 }
 
@@ -3119,7 +3266,8 @@ const void *Magick::Image::getConstMetacontent(void) const
   result=GetVirtualMetacontent(constImage());
 
   if(!result)
-    throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Unable to retrieve meta content.");
 
   return(result);
 }
@@ -3132,7 +3280,8 @@ void *Magick::Image::getMetacontent(void )
   result=GetAuthenticMetacontent(image());
 
   if(!result)
-    throwExceptionExplicit(OptionError,"Unable to retrieve meta content.");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Unable to retrieve meta content.");
 
   return(result);
 }
@@ -3145,8 +3294,8 @@ Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
 
   modifyImage();
   GetPPException;
-  result=(*GetAuthenticPixels)(image(),x_, y_,columns_,rows_,exceptionInfo);
-  ThrowPPException;
+  result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
+  ThrowImageException;
 
   return(result);
 }
@@ -3156,7 +3305,7 @@ void Magick::Image::grayscale(const PixelIntensityMethod method_)
   modifyImage();
   GetPPException;
   (void) GrayscaleImage(image(),method_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void  Magick::Image::haldClut(const Image &clutImage_)
@@ -3164,7 +3313,7 @@ void  Magick::Image::haldClut(const Image &clutImage_)
   modifyImage();
   GetPPException;
   (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::houghLine(const size_t width_,const size_t height_,
@@ -3177,7 +3326,18 @@ void Magick::Image::houghLine(const size_t width_,const size_t height_,
   newImage=HoughLineImage(constImage(),width_,height_,threshold_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+Magick::ImageType Magick::Image::identifyType(void) const
+{
+  ImageType
+    image_type;
+
+  GetPPException;
+  image_type=IdentifyImageType(constImage(),exceptionInfo);
+  ThrowImageException;
+  return(image_type);
 }
 
 void Magick::Image::implode(const double factor_)
@@ -3189,7 +3349,7 @@ void Magick::Image::implode(const double factor_)
   newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::inverseFourierTransform(const Image &phase_)
@@ -3207,7 +3367,7 @@ void Magick::Image::inverseFourierTransform(const Image &phase_,
   newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
     magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::kuwahara(const double radius_,const double sigma_)
@@ -3218,7 +3378,7 @@ void Magick::Image::kuwahara(const double radius_,const double sigma_)
   GetPPException;
   newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::kuwaharaChannel(const ChannelType channel_,
@@ -3228,11 +3388,11 @@ void Magick::Image::kuwaharaChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::level(const double blackPoint_,const double whitePoint_,
@@ -3241,7 +3401,7 @@ void Magick::Image::level(const double blackPoint_,const double whitePoint_,
   modifyImage();
   GetPPException;
   (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::levelChannel(const ChannelType channel_,
@@ -3249,10 +3409,10 @@ void Magick::Image::levelChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::levelColors(const Color &blackColor_,
@@ -3269,7 +3429,7 @@ void Magick::Image::levelColors(const Color &blackColor_,
   GetPPException;
   (void) LevelImageColors(image(),&black,&white,invert_ == true ?
     MagickTrue : MagickFalse,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::levelColorsChannel(const ChannelType channel_,
@@ -3284,11 +3444,31 @@ void Magick::Image::levelColorsChannel(const ChannelType channel_,
   black=static_cast<PixelInfo>(blackColor_);
   white=static_cast<PixelInfo>(whiteColor_);
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   (void) LevelImageColors(image(),&black,&white,invert_ == true ?
     MagickTrue : MagickFalse,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::levelize(const double blackPoint_,const double whitePoint_,
+  const double gamma_)
+{
+  modifyImage();
+  GetPPException;
+  (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
+  ThrowImageException;
+}
+
+void Magick::Image::levelizeChannel(const ChannelType channel_,
+  const double blackPoint_,const double whitePoint_,const double gamma_)
+{
+  modifyImage();
+  GetPPException;
+  GetAndSetPPChannelMask(channel_);
+  (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
+  RestorePPChannelMask;
+  ThrowImageException;
 }
 
 void Magick::Image::linearStretch(const double blackPoint_,
@@ -3297,7 +3477,7 @@ void Magick::Image::linearStretch(const double blackPoint_,
   modifyImage();
   GetPPException;
   LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::liquidRescale(const Geometry &geometry_)
@@ -3319,7 +3499,18 @@ void Magick::Image::liquidRescale(const Geometry &geometry_)
   GetPPException;
   newImage=LiquidRescaleImage(image(),width,height,x,y,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::localContrast(const double radius_,const double strength_)
+{
+  MagickCore::Image
+    *newImage;
+
+  GetPPException;
+  newImage=LocalContrastImage(constImage(),radius_,strength_,exceptionInfo);
+  replaceImage(newImage);
+  ThrowImageException;
 }
 
 void Magick::Image::magnify(void)
@@ -3330,7 +3521,7 @@ void Magick::Image::magnify(void)
   GetPPException;
   newImage=MagnifyImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::map(const Image &mapImage_,const bool dither_)
@@ -3340,7 +3531,7 @@ void Magick::Image::map(const Image &mapImage_,const bool dither_)
   options()->quantizeDither(dither_);
   RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::medianFilter(const double radius_)
@@ -3352,7 +3543,7 @@ void Magick::Image::medianFilter(const double radius_)
   newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
     (size_t) radius_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::minify(void)
@@ -3363,27 +3554,27 @@ void Magick::Image::minify(void)
   GetPPException;
   newImage=MinifyImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::modulate(const double brightness_,const double saturation_,
   const double hue_)
 {
   char
-    modulate[MaxTextExtent + 1];
+    modulate[MagickPathExtent + 1];
 
-  FormatLocaleString(modulate,MaxTextExtent,"%3.6f,%3.6f,%3.6f",brightness_,
+  FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
     saturation_,hue_);
 
   modifyImage();
   GetPPException;
   ModulateImage(image(),modulate,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-Magick::ImageMoments Magick::Image::moments(void)
+Magick::ImageMoments Magick::Image::moments(void) const
 {
-  return(ImageMoments(constImage()));
+  return(ImageMoments(*this));
 }
 
 void Magick::Image::morphology(const MorphologyMethod method_,
@@ -3398,12 +3589,12 @@ void Magick::Image::morphology(const MorphologyMethod method_,
   GetPPException;
   kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
   if (kernel == (KernelInfo *) NULL)
-    throwExceptionExplicit(OptionError,"Unable to parse kernel.");
+    throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
   newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
     exceptionInfo);
   replaceImage(newImage);
   kernel=DestroyKernelInfo(kernel);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::morphology(const MorphologyMethod method_,
@@ -3418,8 +3609,11 @@ void Magick::Image::morphology(const MorphologyMethod method_,
 
   option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
   if (option == (const char *)NULL)
-    throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
-
+    {
+      throwExceptionExplicit(MagickCore::OptionError,
+        "Unable to determine kernel type.");
+      return;
+    }
   kernel=std::string(option);
   if (!arguments_.empty())
     kernel+=":"+arguments_;
@@ -3441,14 +3635,18 @@ void Magick::Image::morphologyChannel(const ChannelType channel_,
   GetPPException;
   kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
   if (kernel == (KernelInfo *)NULL)
-    throwExceptionExplicit(OptionError,"Unable to parse kernel.");
-  SetPPChannelMask(channel_);
+    {
+      throwExceptionExplicit(MagickCore::OptionError,
+        "Unable to parse kernel.");
+      return;
+    }
+  GetAndSetPPChannelMask(channel_);
   newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
     exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
   kernel=DestroyKernelInfo(kernel);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::morphologyChannel(const ChannelType channel_,
@@ -3463,7 +3661,11 @@ void Magick::Image::morphologyChannel(const ChannelType channel_,
 
   option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
   if (option == (const char *)NULL)
-    throwExceptionExplicit(OptionError,"Unable to determine kernel type.");
+    {
+      throwExceptionExplicit(MagickCore::OptionError,
+        "Unable to determine kernel type.");
+      return;
+    }
 
   kernel=std::string(option);
   if (!arguments_.empty())
@@ -3481,7 +3683,7 @@ void Magick::Image::motionBlur(const double radius_,const double sigma_,
   GetPPException;
   newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::negate(const bool grayscale_)
@@ -3489,7 +3691,7 @@ void Magick::Image::negate(const bool grayscale_)
   modifyImage();
   GetPPException;
   NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::negateChannel(const ChannelType channel_,
@@ -3497,10 +3699,10 @@ void Magick::Image::negateChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::normalize(void)
@@ -3508,7 +3710,7 @@ void Magick::Image::normalize(void)
   modifyImage();
   GetPPException;
   NormalizeImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::oilPaint(const double radius_,const double sigma_)
@@ -3519,7 +3721,7 @@ void Magick::Image::oilPaint(const double radius_,const double sigma_)
   GetPPException;
   newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
@@ -3534,10 +3736,12 @@ void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
     pen;
 
   if (!opaqueColor_.isValid())
-    throwExceptionExplicit(OptionError,"Opaque color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Opaque color argument is invalid");
 
   if (!penColor_.isValid())
-    throwExceptionExplicit(OptionError,"Pen color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Pen color argument is invalid");
 
   modifyImage();
   opaqueColor=opaqueColor_;
@@ -3550,7 +3754,7 @@ void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
     exceptionInfo);
   OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::orderedDither(std::string thresholdMap_)
@@ -3558,7 +3762,7 @@ void Magick::Image::orderedDither(std::string thresholdMap_)
   modifyImage();
   GetPPException;
   (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::orderedDitherChannel(const ChannelType channel_,
@@ -3566,10 +3770,10 @@ void Magick::Image::orderedDitherChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::perceptible(const double epsilon_)
@@ -3577,7 +3781,7 @@ void Magick::Image::perceptible(const double epsilon_)
   modifyImage();
   GetPPException;
   PerceptibleImage(image(),epsilon_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::perceptibleChannel(const ChannelType channel_,
@@ -3585,15 +3789,15 @@ void Magick::Image::perceptibleChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   PerceptibleImage(image(),epsilon_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
- Magick::ImagePerceptualHash Magick::Image::perceptualHash()
+ Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
 {
-  return(ImagePerceptualHash(constImage()));
+  return(ImagePerceptualHash(*this));
 }
 
 void Magick::Image::ping(const std::string &imageSpec_)
@@ -3628,7 +3832,8 @@ void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
 
   // Test arguments to ensure they are within the image.
   if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
-    throwExceptionExplicit(OptionError,"Access outside of image boundary");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Access outside of image boundary");
 
   modifyImage();
 
@@ -3674,7 +3879,7 @@ void Magick::Image::polaroid(const std::string &caption_,const double angle_,
   newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
     angle_,method_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
@@ -3682,7 +3887,7 @@ void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
   modifyImage();
   GetPPException;
   PosterizeImage(image(),levels_,method_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::posterizeChannel(const ChannelType channel_,
@@ -3690,10 +3895,10 @@ void Magick::Image::posterizeChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   PosterizeImage(image(),levels_,method_,exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::process(std::string name_,const ssize_t argc,
@@ -3704,7 +3909,7 @@ void Magick::Image::process(std::string name_,const ssize_t argc,
   GetPPException;
   (void) InvokeDynamicImageFilter(name_.c_str(),&image(),argc,argv,
       exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::profile(const std::string name_,
@@ -3714,7 +3919,7 @@ void Magick::Image::profile(const std::string name_,
   GetPPException;
   (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
     profile_.length(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 Magick::Blob Magick::Image::profile(const std::string name_) const
@@ -3741,44 +3946,7 @@ void Magick::Image::quantize(const bool measureError_)
 
   GetPPException;
   QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
-  ThrowPPException;
-}
-
-void Magick::Image::quantumOperator(const ChannelType channel_,
-  const MagickEvaluateOperator operator_,double rvalue_)
-{
-  GetPPException;
-  SetPPChannelMask(channel_);
-  EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
-  RestorePPChannelMask;
-  ThrowPPException;
-}
-
-void Magick::Image::quantumOperator(const ssize_t x_,const ssize_t y_,
-  const size_t columns_,const size_t rows_,const ChannelType channel_,
-  const MagickEvaluateOperator operator_,const double rvalue_)
-{
-  RectangleInfo
-    geometry;
-
-  MagickCore::Image
-    *cropImage;
-
-  geometry.width = columns_;
-  geometry.height = rows_;
-  geometry.x = x_;
-  geometry.y = y_;
-
-  GetPPException;
-  cropImage=CropImage(image(),&geometry,exceptionInfo);
-  SetPPChannelMask(channel_);
-  EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
-  RestorePPChannelMask;
-  (void) CompositeImage(image(),cropImage,image()->alpha_trait == 
-    BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
-    geometry.x,geometry.y,exceptionInfo );
-  cropImage=DestroyImageList(cropImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
@@ -3790,7 +3958,7 @@ void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
   modifyImage();
   RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::randomThreshold(const Geometry &thresholds_)
@@ -3798,7 +3966,7 @@ void Magick::Image::randomThreshold(const Geometry &thresholds_)
   GetPPException;
   (void) RandomThresholdImage(image(),static_cast<std::string>(
     thresholds_).c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::randomThresholdChannel(const ChannelType channel_,
@@ -3806,11 +3974,11 @@ void Magick::Image::randomThresholdChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   (void) RandomThresholdImage(image(),static_cast<std::string>(
     thresholds_).c_str(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::read(const Blob &blob_)
@@ -3875,7 +4043,7 @@ void Magick::Image::read(const size_t width_,const size_t height_,
   newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::read(const std::string &imageSpec_)
@@ -3900,24 +4068,34 @@ void Magick::Image::readPixels(const Magick::QuantumType quantum_,
   ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
     quantum_,source_,exceptionInfo);
   quantum_info=DestroyQuantumInfo(quantum_info);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::reduceNoise(void)
 {
-  reduceNoise(3.0);
+  reduceNoise(3);
 }
 
-void Magick::Image::reduceNoise(const double order_)
+void Magick::Image::reduceNoise(const size_t order_)
 {
   MagickCore::Image
     *newImage;
 
   GetPPException;
-  newImage=StatisticImage(constImage(),NonpeakStatistic,(size_t) order_,
-    (size_t) order_,exceptionInfo);
+  newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
+    order_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::repage()
+{
+  modifyImage();
+  options()->page(Geometry());
+  image()->page.width = 0;
+  image()->page.height = 0;
+  image()->page.x = 0;
+  image()->page.y = 0;
 }
 
 void Magick::Image::resample(const Point &density_)
@@ -3929,7 +4107,7 @@ void Magick::Image::resample(const Point &density_)
   newImage=ResampleImage(constImage(),density_.x(),density_.y(),
     image()->filter,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::resize(const Geometry &geometry_)
@@ -3954,7 +4132,7 @@ void Magick::Image::resize(const Geometry &geometry_)
   newImage=ResizeImage(constImage(),width,height,image()->filter,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::roll(const Geometry &roll_)
@@ -3965,7 +4143,7 @@ void Magick::Image::roll(const Geometry &roll_)
   GetPPException;
   newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::roll(const size_t columns_,const size_t rows_)
@@ -3977,7 +4155,7 @@ void Magick::Image::roll(const size_t columns_,const size_t rows_)
   newImage=RollImage(constImage(),static_cast<ssize_t>(columns_),
     static_cast<ssize_t>(rows_),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::rotate(const double degrees_)
@@ -3988,7 +4166,7 @@ void Magick::Image::rotate(const double degrees_)
   GetPPException;
   newImage=RotateImage(constImage(),degrees_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::rotationalBlur(const double angle_)
@@ -3999,7 +4177,7 @@ void Magick::Image::rotationalBlur(const double angle_)
   GetPPException;
   newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
@@ -4009,11 +4187,11 @@ void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::sample(const Geometry &geometry_)
@@ -4035,7 +4213,7 @@ void Magick::Image::sample(const Geometry &geometry_)
   GetPPException;
   newImage=SampleImage(constImage(),width,height,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::scale(const Geometry &geometry_)
@@ -4057,7 +4235,7 @@ void Magick::Image::scale(const Geometry &geometry_)
   GetPPException;
   newImage=ScaleImage(constImage(),width,height,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::segment(const double clusterThreshold_,
@@ -4069,7 +4247,7 @@ void Magick::Image::segment(const double clusterThreshold_,
     (MagickBooleanType) options()->verbose(),clusterThreshold_,
     smoothingThreshold_,exceptionInfo);
   SyncImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
@@ -4082,7 +4260,7 @@ void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
   newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
@@ -4092,22 +4270,22 @@ void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
     exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-Magick::Image Magick::Image::separate(const ChannelType channel_)
+Magick::Image Magick::Image::separate(const ChannelType channel_) const
 {
   MagickCore::Image
     *image;
 
   GetPPException;
   image=SeparateImage(constImage(),channel_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   if (image == (MagickCore::Image *) NULL)
     return(Magick::Image());
   else
@@ -4122,7 +4300,23 @@ void Magick::Image::sepiaTone(const double threshold_)
   GetPPException;
   newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+bool Magick::Image::setColorMetric(const Image &reference_)
+{
+  bool
+    status;
+
+  Image
+    ref=reference_;
+
+  GetPPException;
+  modifyImage();
+  status=static_cast<bool>(SetImageColorMetric(image(),ref.constImage(),
+    exceptionInfo));
+  ThrowImageException;
+  return(status);
 }
 
 Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
@@ -4133,8 +4327,8 @@ Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
 
   modifyImage();
   GetPPException;
-  result=(*QueueAuthenticPixels)(image(),x_,y_,columns_,rows_,exceptionInfo);
-  ThrowPPException;
+  result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
+  ThrowImageException;
   return(result);
 }
 
@@ -4148,7 +4342,7 @@ void Magick::Image::shade(const double azimuth_,const double elevation_,
   newImage=ShadeImage(constImage(),colorShading_ == true ?
     MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
@@ -4161,7 +4355,7 @@ void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
   newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::sharpen(const double radius_,const double sigma_)
@@ -4172,7 +4366,7 @@ void Magick::Image::sharpen(const double radius_,const double sigma_)
   GetPPException;
   newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::sharpenChannel(const ChannelType channel_,
@@ -4182,11 +4376,11 @@ void Magick::Image::sharpenChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::shave(const Geometry &geometry_)
@@ -4200,7 +4394,7 @@ void Magick::Image::shave(const Geometry &geometry_)
   GetPPException;
   newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
@@ -4211,22 +4405,22 @@ void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
   GetPPException;
   newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-void Magick::Image::sigmoidalContrast(const size_t sharpen_,
+void Magick::Image::sigmoidalContrast(const bool sharpen_,
   const double contrast,const double midpoint)
 {
   modifyImage();
   GetPPException;
   (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
     midpoint,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 std::string Magick::Image::signature(const bool force_) const
 {
-  return(_imgRef->signature());
+  return(_imgRef->signature(force_));
 }
 
 void Magick::Image::sketch(const double radius_,const double sigma_,
@@ -4238,7 +4432,7 @@ void Magick::Image::sketch(const double radius_,const double sigma_,
   GetPPException;
   newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::solarize(const double factor_)
@@ -4246,7 +4440,7 @@ void Magick::Image::solarize(const double factor_)
   modifyImage();
   GetPPException;
   SolarizeImage(image(),factor_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::sparseColor(const ChannelType channel_,
@@ -4257,12 +4451,12 @@ void Magick::Image::sparseColor(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
     exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::splice(const Geometry &geometry_)
@@ -4276,7 +4470,22 @@ void Magick::Image::splice(const Geometry &geometry_)
   GetPPException;
   newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
+}
+
+void Magick::Image::splice(const Geometry &geometry_,
+  const Color &backgroundColor_)
+{
+  backgroundColor(backgroundColor_);
+  splice(geometry_);
+}
+
+void Magick::Image::splice(const Geometry &geometry_,
+  const Color &backgroundColor_,const GravityType gravity_)
+{
+  backgroundColor(backgroundColor_);
+  image()->gravity=gravity_;
+  splice(geometry_);
 }
 
 void Magick::Image::spread(const size_t amount_)
@@ -4285,15 +4494,14 @@ void Magick::Image::spread(const size_t amount_)
     *newImage;
 
   GetPPException;
-  newImage=SpreadImage(constImage(),amount_,image()->interpolate,
-    exceptionInfo);
+  newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-Magick::ImageStatistics Magick::Image::statistics()
+Magick::ImageStatistics Magick::Image::statistics() const
 {
-  return(ImageStatistics(constImage()));
+  return(ImageStatistics(*this));
 }
 
 void Magick::Image::stegano(const Image &watermark_)
@@ -4304,7 +4512,7 @@ void Magick::Image::stegano(const Image &watermark_)
   GetPPException;
   newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::stereo(const Image &rightImage_)
@@ -4315,7 +4523,7 @@ void Magick::Image::stereo(const Image &rightImage_)
   GetPPException;
   newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::strip(void)
@@ -4323,7 +4531,7 @@ void Magick::Image::strip(void)
   modifyImage();
   GetPPException;
   StripImage(image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 Magick::Image Magick::Image::subImageSearch(const Image &reference_,
@@ -4339,7 +4547,7 @@ Magick::Image Magick::Image::subImageSearch(const Image &reference_,
   GetPPException;
   newImage=SimilarityImage(image(),reference_.constImage(),metric_,
     similarityThreshold,&offset,similarityMetric_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   if (offset_ != (Geometry *) NULL)
     *offset_=offset;
   if (newImage == (MagickCore::Image *) NULL)
@@ -4357,14 +4565,14 @@ void Magick::Image::swirl(const double degrees_)
   newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::syncPixels(void)
 {
   GetPPException;
-  (void) (*SyncAuthenticPixels)(image(),exceptionInfo);
-  ThrowPPException;
+  (void) SyncAuthenticPixels(image(),exceptionInfo);
+  ThrowImageException;
 }
 
 void Magick::Image::texture(const Image &texture_)
@@ -4372,7 +4580,7 @@ void Magick::Image::texture(const Image &texture_)
   modifyImage();
   GetPPException;
   TextureImage(image(),texture_.constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::threshold(const double threshold_)
@@ -4380,7 +4588,7 @@ void Magick::Image::threshold(const double threshold_)
   modifyImage();
   GetPPException;
   BilevelImage(image(),threshold_,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::thumbnail(const Geometry &geometry_)
@@ -4402,7 +4610,7 @@ void Magick::Image::thumbnail(const Geometry &geometry_)
   GetPPException;
   newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::tint(const std::string opacity_)
@@ -4417,7 +4625,7 @@ void Magick::Image::tint(const std::string opacity_)
   color=static_cast<PixelInfo>(constOptions()->fillColor());
   newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::transform(const Geometry &imageGeometry_)
@@ -4426,7 +4634,7 @@ void Magick::Image::transform(const Geometry &imageGeometry_)
   GetPPException;
   TransformImage(&(image()),0,std::string(imageGeometry_).c_str(),
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::transform(const Geometry &imageGeometry_,
@@ -4436,7 +4644,7 @@ void Magick::Image::transform(const Geometry &imageGeometry_,
   GetPPException;
   TransformImage(&(image()),std::string(cropGeometry_).c_str(),std::string(
     imageGeometry_).c_str(), exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::transformOrigin(const double x_,const double y_)
@@ -4457,7 +4665,7 @@ void Magick::Image::transformScale(const double sx_,const double sy_)
   options()->transformScale(sx_,sy_);
 }
 
-void Magick::Image::transparent(const Color &color_)
+void Magick::Image::transparent(const Color &color_,const bool inverse_)
 {
   PixelInfo
     target;
@@ -4466,16 +4674,17 @@ void Magick::Image::transparent(const Color &color_)
     color;
 
   if (!color_.isValid())
-    throwExceptionExplicit(OptionError,"Color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Color argument is invalid");
 
   color=color_;
   GetPPException;
   (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
     exceptionInfo);
   modifyImage();
-  TransparentPaintImage(image(),&target,TransparentAlpha,MagickFalse,
-    exceptionInfo);
-  ThrowPPException;
+  TransparentPaintImage(image(),&target,TransparentAlpha,
+    inverse_ == true ? MagickTrue : MagickFalse,exceptionInfo);
+  ThrowImageException;
 }
 
 void Magick::Image::transparentChroma(const Color &colorLow_,
@@ -4490,7 +4699,8 @@ void Magick::Image::transparentChroma(const Color &colorLow_,
     targetLow;
 
   if (!colorLow_.isValid() || !colorHigh_.isValid())
-    throwExceptionExplicit(OptionError,"Color argument is invalid");
+    throwExceptionExplicit(MagickCore::OptionError,
+      "Color argument is invalid");
 
   colorLow=colorLow_;
   colorHigh=colorHigh_;
@@ -4503,7 +4713,7 @@ void Magick::Image::transparentChroma(const Color &colorLow_,
   modifyImage();
   TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
     MagickFalse,exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::transpose(void)
@@ -4514,7 +4724,7 @@ void Magick::Image::transpose(void)
   GetPPException;
   newImage=TransposeImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::transverse(void)
@@ -4525,7 +4735,7 @@ void Magick::Image::transverse(void)
   GetPPException;
   newImage=TransverseImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::trim(void)
@@ -4536,17 +4746,17 @@ void Magick::Image::trim(void)
   GetPPException;
   newImage=TrimImage(constImage(),exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
-Magick::Image Magick::Image::uniqueColors(void)
+Magick::Image Magick::Image::uniqueColors(void) const
 {
   MagickCore::Image
     *image;
 
   GetPPException;
   image=UniqueImageColors(constImage(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
   if (image == (MagickCore::Image *) NULL)
     return(Magick::Image());
   else
@@ -4563,7 +4773,7 @@ void Magick::Image::unsharpmask(const double radius_,const double sigma_,
   newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
@@ -4574,12 +4784,12 @@ void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
     *newImage;
 
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
     exceptionInfo);
   RestorePPChannelMask;
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::vignette(const double radius_,const double sigma_,
@@ -4591,7 +4801,7 @@ void Magick::Image::vignette(const double radius_,const double sigma_,
   GetPPException;
   newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::wave(const double amplitude_,const double wavelength_)
@@ -4603,7 +4813,7 @@ void Magick::Image::wave(const double amplitude_,const double wavelength_)
   newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
     exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::whiteThreshold(const std::string &threshold_)
@@ -4611,7 +4821,7 @@ void Magick::Image::whiteThreshold(const std::string &threshold_)
   modifyImage();
   GetPPException;
   WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
@@ -4619,10 +4829,10 @@ void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
 {
   modifyImage();
   GetPPException;
-  SetPPChannelMask(channel_);
+  GetAndSetPPChannelMask(channel_);
   WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
   RestorePPChannelMask;
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::write(Blob *blob_)
@@ -4638,7 +4848,7 @@ void Magick::Image::write(Blob *blob_)
   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
   if (length > 0)
     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::write(Blob *blob_,const std::string &magick_)
@@ -4655,7 +4865,7 @@ void Magick::Image::write(Blob *blob_,const std::string &magick_)
   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
   if (length > 0)
     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::write(Blob *blob_,const std::string &magick_,
@@ -4674,7 +4884,7 @@ void Magick::Image::write(Blob *blob_,const std::string &magick_,
   data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
   if (length > 0)
     blob_->updateNoCopy(data,length,Blob::MallocAllocator);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::write(const ssize_t x_,const ssize_t y_,
@@ -4684,7 +4894,7 @@ void Magick::Image::write(const ssize_t x_,const ssize_t y_,
   GetPPException;
   ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
     exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::write(const std::string &imageSpec_)
@@ -4693,7 +4903,7 @@ void Magick::Image::write(const std::string &imageSpec_)
   fileName(imageSpec_);
   GetPPException;
   WriteImage(constImageInfo(),image(),exceptionInfo);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::writePixels(const Magick::QuantumType quantum_,
@@ -4707,7 +4917,7 @@ void Magick::Image::writePixels(const Magick::QuantumType quantum_,
   ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
     quantum_,destination_, exceptionInfo);
   quantum_info=DestroyQuantumInfo(quantum_info);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::zoom(const Geometry &geometry_)
@@ -4729,7 +4939,7 @@ void Magick::Image::zoom(const Geometry &geometry_)
   GetPPException;
   newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
   replaceImage(newImage);
-  ThrowPPException;
+  ThrowImageException;
 }
 
 Magick::Image::Image(MagickCore::Image *image_)
@@ -4779,12 +4989,12 @@ const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
 
 void Magick::Image::modifyImage(void)
 {
-  if (_imgRef->isOwner())
+  if (!_imgRef->isShared())
     return;
 
   GetPPException;
   replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
-  ThrowPPException;
+  ThrowImageException;
 }
 
 MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
@@ -4798,19 +5008,10 @@ MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
     {
       GetPPException;
       image=AcquireImage(constImageInfo(),exceptionInfo);
-      ThrowPPException;
-    }
-
-  // We can replace the image if we own it.
-  if (!_imgRef->replaceImage(image))
-    {
-      // We don't own the image, dereference and replace with new reference
-      if (_imgRef->decrease() == 0)
-        delete _imgRef;
-
-      _imgRef=new ImageRef(image,constOptions());
+      ThrowImageException;
     }
 
+  _imgRef=ImageRef::replaceImage(_imgRef,image);
   return(image);
 }
 
@@ -4835,9 +5036,11 @@ void Magick::Image::read(MagickCore::Image *image,
       image == (MagickCore::Image *) NULL)
     {
       (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
-      throwExceptionExplicit(ImageWarning,"No image was loaded.");
+      if (!quiet())
+        throwExceptionExplicit(MagickCore::ImageWarning,
+          "No image was loaded.");
     }
-  ThrowPPException;
+  ThrowImageException;
 }
 
 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
@@ -4858,7 +5061,7 @@ void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
       GetPPException;
       fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
         exceptionInfo);
-      ThrowPPException;
+      ThrowImageException;
     }
 
   if (fillPattern_ == (Magick::Image *)NULL)
@@ -4876,5 +5079,5 @@ void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
 
   options()->fillColor(fillColor);
   options()->fillPattern(fillPattern);
-  ThrowPPException;
+  ThrowImageException;
 }