/// <summary> Compares a current and previous version of an image and returns a diff image if they differ </summary> /// <param name="self">The current version of the image </param> /// <param name="imgFile"> The file where the previous version of the image is stored in </param> /// <param name="maxAllowedDiff"> A good value to start testing with would be e.g. 0.0005 </param> /// <returns> null if the images do not differ, a diff image otherwise </returns> public static FileEntry Compare(this MagickImage self, FileEntry imgFile, ErrorMetric errorMetric, double maxAllowedDiff) { using (MagickImage oldImg = new MagickImage()) { oldImg.LoadFromFileEntry(imgFile); double diffValue = self.CompareV2(oldImg, errorMetric, out MagickImage imgWithDifferences); var diffDetected = diffValue > maxAllowedDiff; // Log.d($"Visual difference of current scene VS image '{imgFile.Name}' is: {diffValue} vs {maxAllowedDiff} (max allowed diff)"); FileEntry diffFile = imgFile.Parent.GetChild(imgFile.NameWithoutExtension + ".diff" + imgFile.ExtensionWithDot); imgWithDifferences.SaveToFileEntry(diffFile); imgWithDifferences.Dispose(); return(diffDetected ? diffFile : null); } }