renderdiff: add golden repo support (#8689)

- Add GoldenManager to manage access to the repo containing the
  goldens
- Add tif comparison code
- Enable comparison by default for actual test
This commit is contained in:
Powei Feng
2025-05-07 14:20:22 -07:00
committed by GitHub
parent 9683eb649c
commit 28ecf5c35d
6 changed files with 201 additions and 45 deletions

View File

@@ -0,0 +1,29 @@
import tifffile
import numpy
def same_image(tiff_file_a, tiff_file_b):
try:
img1_data = tifffile.imread(tiff_file_a)
img2_data = tifffile.imread(tiff_file_b)
# If the dimensions (height, width, number of channels, number of pages/frames)
# are different, the images are not the same.
if img1_data.shape != img2_data.shape:
print(f"Images have different shapes: {img1_data.shape} vs {img2_data.shape}")
return False
# numpy.array_equal() checks if two arrays have the same shape and elements.
if numpy.array_equal(img1_data, img2_data):
return True
else:
return False
except FileNotFoundError:
print(f"Error: One or both files not found ('{file_path1}', '{file_path2}').")
return False
except tifffile.TiffFileError as e:
print(f"Error: One or both files are not valid TIFF files or could not be read. Details: {e}")
return False
except Exception as e:
print(f"An unexpected error occurred: {e}")
return False