Commit f72f5b846 for imagemagick.org
commit f72f5b846b90d3631f3ce79fc2abe8308531c402
Author: Cristy <urban-warrior@imagemagick.org>
Date: Sat May 30 13:37:07 2026 -0400
use absolute values for PHASH logs
diff --git a/MagickCore/statistic-private.h b/MagickCore/statistic-private.h
index b10e0e923..d61aa8dd4 100644
--- a/MagickCore/statistic-private.h
+++ b/MagickCore/statistic-private.h
@@ -29,15 +29,13 @@ static inline MagickBooleanType MagickSafeSignificantError(const double error,
return(error > threshold ? MagickTrue : MagickFalse);
}
-#define MagickLogEpsilon 1.0e-30
-
static inline double MagickSafeLog10(const double x)
{
if (x <= 0.0)
- return(log10(MagickLogEpsilon));
- if (x < MagickLogEpsilon)
- return(log10(MagickLogEpsilon));
- if (fabs(x-1.0) < MagickLogEpsilon)
+ return(log10(MagickEpsilon));
+ if (x < MagickEpsilon)
+ return(log10(MagickEpsilon));
+ if (fabs(x-1.0) < MagickEpsilon)
return(0.0);
return(log10(x));
}
diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c
index 391d03285..2b2f9893c 100644
--- a/MagickCore/statistic.c
+++ b/MagickCore/statistic.c
@@ -328,7 +328,7 @@ static double ApplyEvaluateOperator(RandomInfo *random_info,const Quantum pixel,
}
case LogEvaluateOperator:
{
- if ((QuantumScale*(double) pixel) >= MagickLogEpsilon)
+ if ((QuantumScale*(double) pixel) >= MagickEpsilon)
result=(double) QuantumRange*log(QuantumScale*value*
(double) pixel+1.0)/log((double) (value+1.0));
break;
@@ -1794,7 +1794,7 @@ MagickExport ChannelPerceptualHash *GetImagePerceptualHash(const Image *image,
for (channel=0; channel <= MaxPixelChannels; channel++)
for (j=0; j < MaximumNumberOfImageMoments; j++)
perceptual_hash[channel].phash[i][j]=
- (-MagickSafeLog10(moments[channel].invariant[j]));
+ (-MagickSafeLog10(fabs(moments[channel].invariant[j])));
moments=(ChannelMoments *) RelinquishMagickMemory(moments);
}
colorspaces=DestroyString(colorspaces);