]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/fx.c
Update web pages
[imagemagick] / MagickCore / fx.c
index 833927b4a80556cf73c872b6aa9fe94ed65ae8a5..9e765c3ab84eea08a22b11116d803856c3527f84 100644 (file)
@@ -294,11 +294,11 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
     Initialize noise image attributes.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   noise_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (noise_image == (Image *) NULL)
     return((Image *) NULL);
@@ -451,11 +451,11 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
     Allocate blue shift image.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   shift_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (shift_image == (Image *) NULL)
     return((Image *) NULL);
@@ -593,11 +593,11 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
     *edge_image;
 
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
   if (clone_image == (Image *) NULL)
     return((Image *) NULL);
@@ -683,11 +683,11 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
     Allocate colorized image.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   colorize_image=CloneImage(image,0,0,MagickTrue,exception);
   if (colorize_image == (Image *) NULL)
     return((Image *) NULL);
@@ -876,11 +876,11 @@ MagickExport Image *ColorMatrixImage(const Image *image,
     Map given color_matrix, into a 6x6 matrix   RGBKA and a constant
   */
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   i=0;
   for (v=0; v < (ssize_t) color_matrix->height; v++)
     for (u=0; u < (ssize_t) color_matrix->width; u++)
@@ -1122,7 +1122,7 @@ static double FxChannelStatistics(FxInfo *fx_info,Image *image,
         {
           channel=(PixelChannel) option;
           channel_mask=(ChannelType) (channel_mask | (1 << channel));
-          SetPixelChannelMask(image,channel_mask);
+          (void) SetPixelChannelMask(image,channel_mask);
         }
     }
   (void) FormatLocaleString(key,MagickPathExtent,"%p.%.20g.%s",(void *) image,
@@ -1131,7 +1131,7 @@ static double FxChannelStatistics(FxInfo *fx_info,Image *image,
   if (value != (const char *) NULL)
     {
       if (channel_mask != UndefinedChannel)
-        SetPixelChannelMask(image,channel_mask);
+        (void) SetPixelChannelMask(image,channel_mask);
       return(QuantumScale*StringToDouble(value,(char **) NULL));
     }
   (void) DeleteNodeFromSplayTree(fx_info->symbols,key);
@@ -1199,7 +1199,7 @@ static double FxChannelStatistics(FxInfo *fx_info,Image *image,
         standard_deviation);
     }
   if (channel_mask != UndefinedChannel)
-    SetPixelChannelMask(image,channel_mask);
+    (void) SetPixelChannelMask(image,channel_mask);
   (void) AddValueToSplayTree(fx_info->symbols,ConstantString(key),
     ConstantString(statistic));
   return(QuantumScale*StringToDouble(statistic,(char **) NULL));
@@ -1207,7 +1207,7 @@ static double FxChannelStatistics(FxInfo *fx_info,Image *image,
 
 static double
   FxEvaluateSubexpression(FxInfo *,const PixelChannel,const ssize_t,
-    const ssize_t,const char *,double *,ExceptionInfo *);
+    const ssize_t,const char *,size_t *,double *,ExceptionInfo *);
 
 static MagickOffsetType FxGCD(MagickOffsetType alpha,MagickOffsetType beta)
 {
@@ -1273,11 +1273,13 @@ static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     i;
 
   size_t
+    depth,
     length,
     level;
 
   p=expression;
   i=GetImageIndexInList(fx_info->images);
+  depth=0;
   level=0;
   point.x=(double) x;
   point.y=(double) y;
@@ -1316,7 +1318,7 @@ static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
               }
               *q='\0';
               alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,
-                &beta,exception);
+                &depth,&beta,exception);
               i=(ssize_t) (alpha+0.5);
               p++;
             }
@@ -1345,7 +1347,7 @@ static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
               }
               *q='\0';
               alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,
-                &beta,exception);
+                &depth,&beta,exception);
               point.x=alpha;
               point.y=beta;
               p++;
@@ -1370,7 +1372,7 @@ static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
                 }
                 *q='\0';
                 alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,
-                  &beta,exception);
+                  &depth,&beta,exception);
                 point.x+=alpha;
                 point.y+=beta;
                 p++;
@@ -1748,6 +1750,13 @@ static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
         return((double) image->page.y);
       break;
     }
+    case 'Q':
+    case 'q':
+    {
+      if (LocaleCompare(symbol,"quality") == 0)
+        return((double) image->quality);
+      break;
+    }
     case 'R':
     case 'r':
     {
@@ -2083,8 +2092,10 @@ static const char *FxOperatorPrecedence(const char *expression,
 
 static double FxEvaluateSubexpression(FxInfo *fx_info,
   const PixelChannel channel,const ssize_t x,const ssize_t y,
-  const char *expression,double *beta,ExceptionInfo *exception)
+  const char *expression,size_t *depth,double *beta,ExceptionInfo *exception)
 {
+#define FxMaxParenthesisDepth  58
+
   char
     *q,
     subexpression[MagickPathExtent];
@@ -2109,36 +2120,40 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       (void) CopyMagickString(subexpression,expression,(size_t)
         (p-expression+1));
-      alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,beta,
-        exception);
+      alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,depth,
+        beta,exception);
       switch ((unsigned char) *p)
       {
         case '~':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=(double) (~(size_t) *beta);
           return(*beta);
         }
         case '!':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(*beta == 0.0 ? 1.0 : 0.0);
         }
         case '^':
         {
           *beta=pow((double) alpha,(double) FxEvaluateSubexpression(fx_info,
-            channel,x,y,++p,beta,exception));
+            channel,x,y,++p,depth,beta,exception));
           return(*beta);
         }
         case '*':
         case ExponentialNotation:
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha*(*beta));
         }
         case '/':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           if (*beta == 0.0)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
@@ -2149,7 +2164,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
         case '%':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=fabs(floor(((double) *beta)+0.5));
           if (*beta == 0.0)
             {
@@ -2161,78 +2177,104 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
         case '+':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha+(*beta));
         }
         case '-':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha-(*beta));
         }
         case LeftShiftOperator:
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=(double) ((size_t) (alpha+0.5) << (size_t) (gamma+0.5));
           return(*beta);
         }
         case RightShiftOperator:
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=(double) ((size_t) (alpha+0.5) >> (size_t) (gamma+0.5));
           return(*beta);
         }
         case '<':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha < *beta ? 1.0 : 0.0);
         }
         case LessThanEqualOperator:
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha <= *beta ? 1.0 : 0.0);
         }
         case '>':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha > *beta ? 1.0 : 0.0);
         }
         case GreaterThanEqualOperator:
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha >= *beta ? 1.0 : 0.0);
         }
         case EqualOperator:
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(fabs(alpha-(*beta)) < MagickEpsilon ? 1.0 : 0.0);
         }
         case NotEqualOperator:
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(fabs(alpha-(*beta)) >= MagickEpsilon ? 1.0 : 0.0);
         }
         case '&':
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=(double) ((size_t) (alpha+0.5) & (size_t) (gamma+0.5));
           return(*beta);
         }
         case '|':
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           *beta=(double) ((size_t) (alpha+0.5) | (size_t) (gamma+0.5));
           return(*beta);
         }
         case LogicalAndOperator:
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(alpha > 0.0) && (gamma > 0.0) ? 1.0 : 0.0;
+          p++;
+          if (alpha <= 0.0)
+            {
+              *beta=0.0;
+              return(*beta);
+            }
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
+            exception);
+          *beta=(gamma > 0.0) ? 1.0 : 0.0;
           return(*beta);
         }
         case LogicalOrOperator:
         {
-          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(alpha > 0.0) || (gamma > 0.0) ? 1.0 : 0.0;
+          p++;
+          if (alpha > 0.0)
+            {
+             *beta=1.0;
+             return(*beta);
+            }
+          gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
+            exception);
+          *beta=(gamma > 0.0) ? 1.0 : 0.0;
           return(*beta);
         }
         case '?':
@@ -2250,9 +2292,11 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
               return(0.0);
             }
           if (fabs((double) alpha) >= MagickEpsilon)
-            gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,beta,exception);
+            gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
+              exception);
           else
-            gamma=FxEvaluateSubexpression(fx_info,channel,x,y,q,beta,exception);
+            gamma=FxEvaluateSubexpression(fx_info,channel,x,y,q,depth,beta,
+              exception);
           return(gamma);
         }
         case '=':
@@ -2270,7 +2314,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
               return(0.0);
             }
           ClearMagickException(exception);
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           (void) FormatLocaleString(numeric,MagickPathExtent,"%g",(double)
             *beta);
           (void) DeleteNodeFromSplayTree(fx_info->symbols,subexpression);
@@ -2280,17 +2325,19 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
         case ',':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(alpha);
         }
         case ';':
         {
-          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
+          *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
+            exception);
           return(*beta);
         }
         default:
         {
-          gamma=alpha*FxEvaluateSubexpression(fx_info,channel,x,y,p,beta,
+          gamma=alpha*FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
             exception);
           return(gamma);
         }
@@ -2298,29 +2345,34 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     }
   if (strchr("(",(int) *expression) != (char *) NULL)
     {
+      (*depth)++;
+      if (*depth >= FxMaxParenthesisDepth)
+        (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+          "ParenthesisNestedTooDeeply","`%s'",expression);
       (void) CopyMagickString(subexpression,expression+1,MagickPathExtent);
       subexpression[strlen(subexpression)-1]='\0';
-      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,beta,
-        exception);
+      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,depth,
+        beta,exception);
+      (*depth)--;
       return(gamma);
     }
   switch (*expression)
   {
     case '+':
     {
-      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
+      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
       return(1.0*gamma);
     }
     case '-':
     {
-      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
+      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
       return(-1.0*gamma);
     }
     case '~':
     {
-      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
+      gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
       return((double) (~(size_t) (gamma+0.5)));
     }
@@ -2329,29 +2381,29 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"abs",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) fabs((double) alpha));
         }
 #if defined(MAGICKCORE_HAVE_ACOSH)
       if (LocaleNCompare(expression,"acosh",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) acosh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"acos",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) acos((double) alpha));
         }
 #if defined(MAGICKCORE_HAVE_J1)
       if (LocaleNCompare(expression,"airy",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           if (alpha == 0.0)
             return(1.0);
           gamma=2.0*j1((double) (MagickPI*alpha))/(MagickPI*alpha);
@@ -2361,41 +2413,41 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
 #if defined(MAGICKCORE_HAVE_ASINH)
       if (LocaleNCompare(expression,"asinh",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) asinh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"asin",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) asin((double) alpha));
         }
       if (LocaleNCompare(expression,"alt",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
         }
       if (LocaleNCompare(expression,"atan2",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) atan2((double) alpha,(double) *beta));
         }
 #if defined(MAGICKCORE_HAVE_ATANH)
       if (LocaleNCompare(expression,"atanh",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) atanh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"atan",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) atan((double) alpha));
         }
       if (LocaleCompare(expression,"a") == 0)
@@ -2414,14 +2466,14 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"ceil",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) ceil((double) alpha));
         }
       if (LocaleNCompare(expression,"clamp",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           if (alpha < 0.0)
             return(0.0);
           if (alpha > 1.0)
@@ -2430,14 +2482,14 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
       if (LocaleNCompare(expression,"cosh",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) cosh((double) alpha));
         }
       if (LocaleNCompare(expression,"cos",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) cos((double) alpha));
         }
       if (LocaleCompare(expression,"c") == 0)
@@ -2452,8 +2504,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           const char
             *type;
 
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           if (fx_info->images->colorspace == CMYKColorspace)
             switch (channel)
             {
@@ -2484,8 +2536,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
       if (LocaleNCompare(expression,"drc",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) (alpha/(*beta*(alpha-1.0)+1.0)));
         }
       break;
@@ -2497,8 +2549,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         return((double) MagickEpsilon);
       if (LocaleNCompare(expression,"exp",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) exp((double) alpha));
         }
       if (LocaleCompare(expression,"e") == 0)
@@ -2510,8 +2562,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"floor",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) floor((double) alpha));
         }
       break;
@@ -2521,8 +2573,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"gauss",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           gamma=exp((double) (-alpha*alpha/2.0))/sqrt(2.0*MagickPI);
           return((double) gamma);
         }
@@ -2531,8 +2583,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           MagickOffsetType
             gcd;
 
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           gcd=FxGCD((MagickOffsetType) (alpha+0.5),(MagickOffsetType) (*beta+
             0.5));
           return((double) gcd);
@@ -2550,8 +2602,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"hypot",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) hypot((double) alpha,(double) *beta));
         }
       break;
@@ -2570,18 +2622,16 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"int",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) floor(alpha));
         }
-#if defined(MAGICKCORE_HAVE_ISNAN)
       if (LocaleNCompare(expression,"isnan",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
-          return((double) !!isnan((double) alpha));
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
+          return((double) !!IsNaN((double) alpha));
         }
-#endif
       if (LocaleCompare(expression,"i") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2594,24 +2644,24 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
 #if defined(MAGICKCORE_HAVE_J0)
       if (LocaleNCompare(expression,"j0",2) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
+            beta,exception);
           return((double) j0((double) alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
       if (LocaleNCompare(expression,"j1",2) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
+            beta,exception);
           return((double) j1((double) alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
       if (LocaleNCompare(expression,"jinc",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           if (alpha == 0.0)
             return(1.0);
           gamma=(double) (2.0*j1((double) (MagickPI*alpha))/(MagickPI*alpha));
@@ -2625,20 +2675,20 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"ln",2) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
+            beta,exception);
           return((double) log((double) alpha));
         }
       if (LocaleNCompare(expression,"logtwo",6) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,depth,
+            beta,exception);
           return((double) log10((double) alpha))/log10(2.0);
         }
       if (LocaleNCompare(expression,"log",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) log10((double) alpha));
         }
       if (LocaleCompare(expression,"lightness") == 0)
@@ -2654,22 +2704,22 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         break;
       if (LocaleNCompare(expression,"max",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return(alpha > *beta ? alpha : *beta);
         }
       if (LocaleNCompare(expression,"minima",6) == 0)
         break;
       if (LocaleNCompare(expression,"min",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return(alpha < *beta ? alpha : *beta);
         }
       if (LocaleNCompare(expression,"mod",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           gamma=alpha-floor((double) (alpha/(*beta)))*(*beta);
           return(gamma);
         }
@@ -2682,8 +2732,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"not",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) (alpha < MagickEpsilon));
         }
       if (LocaleCompare(expression,"n") == 0)
@@ -2708,8 +2758,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         return((double) MagickPI);
       if (LocaleNCompare(expression,"pow",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) pow((double) alpha,(double) *beta));
         }
       if (LocaleCompare(expression,"p") == 0)
@@ -2741,8 +2791,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
       if (LocaleNCompare(expression,"round",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           return((double) floor((double) alpha+0.5));
         }
       if (LocaleCompare(expression,"r") == 0)
@@ -2756,14 +2806,14 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"sign",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return(alpha < 0.0 ? -1.0 : 1.0);
         }
       if (LocaleNCompare(expression,"sinc",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           if (alpha == 0)
             return(1.0);
           gamma=(double) (sin((double) (MagickPI*alpha))/
@@ -2772,26 +2822,26 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         }
       if (LocaleNCompare(expression,"sinh",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) sinh((double) alpha));
         }
       if (LocaleNCompare(expression,"sin",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) sin((double) alpha));
         }
       if (LocaleNCompare(expression,"sqrt",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) sqrt((double) alpha));
         }
       if (LocaleNCompare(expression,"squish",6) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,depth,
+            beta,exception);
           return((double) (1.0/(1.0+exp((double) (-alpha)))));
         }
       if (LocaleCompare(expression,"s") == 0)
@@ -2803,22 +2853,22 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       if (LocaleNCompare(expression,"tanh",4) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
+            beta,exception);
           return((double) tanh((double) alpha));
         }
       if (LocaleNCompare(expression,"tan",3) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
+            beta,exception);
           return((double) tan((double) alpha));
         }
       if (LocaleCompare(expression,"Transparent") == 0)
         return(0.0);
       if (LocaleNCompare(expression,"trunc",5) == 0)
         {
-          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-            exception);
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
+            beta,exception);
           if (alpha >= 0.0)
             return((double) floor((double) alpha));
           return((double) ceil((double) alpha));
@@ -2848,8 +2898,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           do
           {
-            alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
-              exception);
+            alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
+              depth,beta,exception);
           } while (fabs((double) alpha) >= MagickEpsilon);
           return((double) *beta);
         }
@@ -2916,9 +2966,13 @@ MagickPrivate MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
   double
     beta;
 
+  size_t
+    depth;
+
+  depth=0;
   beta=0.0;
-  *alpha=FxEvaluateSubexpression(fx_info,channel,x,y,fx_info->expression,&beta,
-    exception);
+  *alpha=FxEvaluateSubexpression(fx_info,channel,x,y,fx_info->expression,&depth,
+    &beta,exception);
   return(exception->severity == OptionError ? MagickFalse : MagickTrue);
 }
 \f
@@ -3037,7 +3091,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
     y;
 
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   fx_info=AcquireFxThreadSet(image,expression,exception);
@@ -3211,11 +3265,11 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
     Initialize implode image attributes.
   */
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   implode_image=CloneImage(image,image->columns,image->rows,MagickTrue,
     exception);
   if (implode_image == (Image *) NULL)
@@ -3416,11 +3470,11 @@ MagickExport Image *MorphImages(const Image *image,const size_t number_frames,
     Clone first frame in sequence.
   */
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   morph_images=CloneImage(image,0,0,MagickTrue,exception);
   if (morph_images == (Image *) NULL)
     return((Image *) NULL);
@@ -3632,6 +3686,10 @@ static inline Quantum PlasmaPixel(RandomInfo *random_info,
 
   plasma=ClampToQuantum(pixel+noise*GetPseudoRandomValue(random_info)-
     noise/2.0);
+  if (plasma <= 0)
+    return((Quantum) 0);
+  if (plasma >= QuantumRange)
+    return(QuantumRange);
   return(plasma);
 }
 
@@ -3659,10 +3717,14 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
     y,
     y_mid;
 
-  if (((segment->x2-segment->x1) == 0.0) && ((segment->y2-segment->y1) == 0.0))
+  if ((fabs(segment->x2-segment->x1) <= MagickEpsilon) &&
+      (fabs(segment->y2-segment->y1) <= MagickEpsilon))
     return(MagickTrue);
   if (depth != 0)
     {
+      MagickBooleanType
+        status;
+
       SegmentInfo
         local_info;
 
@@ -3691,19 +3753,23 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
       local_info=(*segment);
       local_info.x1=(double) x_mid;
       local_info.y1=(double) y_mid;
-      return(PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
-        &local_info,attenuate,depth,exception));
+      status=PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
+        &local_info,attenuate,depth,exception);
+      return(status);
     }
   x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
   y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
-  if ((segment->x1 == (double) x_mid) && (segment->x2 == (double) x_mid) &&
-      (segment->y1 == (double) y_mid) && (segment->y2 == (double) y_mid))
+  if ((fabs(segment->x1-x_mid) < MagickEpsilon) &&
+      (fabs(segment->x2-x_mid) < MagickEpsilon) &&
+      (fabs(segment->y1-y_mid) < MagickEpsilon) &&
+      (fabs(segment->y2-y_mid) < MagickEpsilon))
     return(MagickFalse);
   /*
     Average pixels and apply plasma.
   */
   plasma=(double) QuantumRange/(2.0*attenuate);
-  if ((segment->x1 != (double) x_mid) || (segment->x2 != (double) x_mid))
+  if ((fabs(segment->x1-x_mid) > MagickEpsilon) ||
+      (fabs(segment->x2-x_mid) > MagickEpsilon))
     {
       /*
         Left pixel.
@@ -3726,7 +3792,7 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
         q[i]=PlasmaPixel(random_info,(u[i]+v[i])/2.0,plasma);
       }
       (void) SyncCacheViewAuthenticPixels(image_view,exception);
-      if (segment->x1 != segment->x2)
+      if (fabs(segment->x1-segment->x2) > MagickEpsilon)
         {
           /*
             Right pixel.
@@ -3751,9 +3817,11 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
     }
-  if ((segment->y1 != (double) y_mid) || (segment->y2 != (double) y_mid))
+  if ((fabs(segment->y1-y_mid) > MagickEpsilon) ||
+      (fabs(segment->y2-y_mid) > MagickEpsilon))
     {
-      if ((segment->x1 != (double) x_mid) || (segment->y2 != (double) y_mid))
+      if ((fabs(segment->x1-x_mid) > MagickEpsilon) ||
+          (fabs(segment->y2-y_mid) > MagickEpsilon))
         {
           /*
             Bottom pixel.
@@ -3777,7 +3845,7 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
           }
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
-      if (segment->y1 != segment->y2)
+      if (fabs(segment->y1-segment->y2) > MagickEpsilon)
         {
           /*
             Top pixel.
@@ -3802,7 +3870,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
     }
-  if ((segment->x1 != segment->x2) || (segment->y1 != segment->y2))
+  if ((fabs(segment->x1-segment->x2) > MagickEpsilon) ||
+      (fabs(segment->y1-segment->y2) > MagickEpsilon))
     {
       /*
         Middle pixel.
@@ -3827,7 +3896,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
       }
       (void) SyncCacheViewAuthenticPixels(image_view,exception);
     }
-  if (((segment->x2-segment->x1) < 3.0) && ((segment->y2-segment->y1) < 3.0))
+  if ((fabs(segment->x2-segment->x1) < 3.0) &&
+      (fabs(segment->y2-segment->y1) < 3.0))
     return(MagickTrue);
   return(MagickFalse);
 }
@@ -3850,7 +3920,7 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
@@ -3925,11 +3995,11 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
     Simulate a Polaroid picture.
   */
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   quantum=(ssize_t) MagickMax(MagickMax((double) image->columns,(double)
     image->rows)/25.0,10.0);
   height=image->rows+2*quantum;
@@ -4115,11 +4185,11 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
     Initialize sepia-toned image attributes.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   sepia_image=CloneImage(image,0,0,MagickTrue,exception);
   if (sepia_image == (Image *) NULL)
     return((Image *) NULL);
@@ -4270,11 +4340,11 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
     y;
 
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
   if (clone_image == (Image *) NULL)
     return((Image *) NULL);
@@ -4343,7 +4413,7 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
   border_image=DestroyImage(border_image);
   if (shadow_image == (Image *) NULL)
     return((Image *) NULL);
-  SetPixelChannelMask(shadow_image,channel_mask);
+  (void) SetPixelChannelMask(shadow_image,channel_mask);
   if (shadow_image->page.width == 0)
     shadow_image->page.width=shadow_image->columns;
   if (shadow_image->page.height == 0)
@@ -4568,7 +4638,7 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
     y;
 
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (IsGrayColorspace(image->colorspace) != MagickFalse)
@@ -4730,13 +4800,13 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
     Initialize steganographic image attributes.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(watermark != (const Image *) NULL);
-  assert(watermark->signature == MagickSignature);
+  assert(watermark->signature == MagickCoreSignature);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   one=1UL;
   stegano_image=CloneImage(image,0,0,MagickTrue,exception);
   if (stegano_image == (Image *) NULL)
@@ -4892,14 +4962,14 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
     y;
 
   assert(left_image != (const Image *) NULL);
-  assert(left_image->signature == MagickSignature);
+  assert(left_image->signature == MagickCoreSignature);
   if (left_image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       left_image->filename);
   assert(right_image != (const Image *) NULL);
-  assert(right_image->signature == MagickSignature);
+  assert(right_image->signature == MagickCoreSignature);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   assert(right_image != (const Image *) NULL);
   image=left_image;
   if ((left_image->columns != right_image->columns) ||
@@ -5035,11 +5105,11 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     Initialize swirl image attributes.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   swirl_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (swirl_image == (Image *) NULL)
     return((Image *) NULL);
@@ -5245,11 +5315,11 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
     Allocate tint image.
   */
   assert(image != (const Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   tint_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (tint_image == (Image *) NULL)
     return((Image *) NULL);
@@ -5286,7 +5356,7 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
       if ((flags & ChiValue) != 0)
         color_vector.alpha=geometry_info.chi;
     }
-  intensity=(double) GetPixelInfoIntensity(image,tint);
+  intensity=(double) GetPixelInfoIntensity((const Image *) NULL,tint);
   color_vector.red=(double) (color_vector.red*tint->red/100.0-intensity);
   color_vector.green=(double) (color_vector.green*tint->green/100.0-intensity);
   color_vector.blue=(double) (color_vector.blue*tint->blue/100.0-intensity);
@@ -5437,11 +5507,11 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
     *vignette_image;
 
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   canvas_image=CloneImage(image,0,0,MagickTrue,exception);
   if (canvas_image == (Image *) NULL)
     return((Image *) NULL);
@@ -5555,11 +5625,11 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
     Initialize wave image attributes.
   */
   assert(image != (Image *) NULL);
-  assert(image->signature == MagickSignature);
+  assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   wave_image=CloneImage(image,image->columns,(size_t) (image->rows+2.0*
     fabs(amplitude)),MagickTrue,exception);
   if (wave_image == (Image *) NULL)