Fix libreoffice impress evaluation (#209)
Co-authored-by: chenjix <211250101@smail.nju.edu.cn>
This commit is contained in:
@@ -389,10 +389,22 @@ def evaluate_presentation_fill_to_rgb_distance(pptx_file, rules):
|
||||
except:
|
||||
original_rgb = None
|
||||
|
||||
def get_rgb_from_color(color):
|
||||
try:
|
||||
if hasattr(color, "rgb"):
|
||||
return color.rgb
|
||||
else:
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
|
||||
def slide_fill_distance_to_rgb(_slide, _rgb, _original_rgb):
|
||||
fill = _slide.background.fill
|
||||
if fill.type == 1:
|
||||
r1, g1, b1 = fill.fore_color.rgb
|
||||
color_rgb = get_rgb_from_color(fill.fore_color)
|
||||
if color_rgb is None:
|
||||
return 1
|
||||
r1, g1, b1 = color_rgb
|
||||
r2, g2, b2 = _rgb
|
||||
|
||||
if _original_rgb is not None:
|
||||
@@ -404,7 +416,10 @@ def evaluate_presentation_fill_to_rgb_distance(pptx_file, rules):
|
||||
elif fill.type == 5:
|
||||
master_fill = _slide.slide_layout.slide_master.background.fill
|
||||
if master_fill.type == 1:
|
||||
r1, g1, b1 = master_fill.fore_color.rgb
|
||||
color_rgb = get_rgb_from_color(master_fill.fore_color)
|
||||
if color_rgb is None:
|
||||
return 1
|
||||
r1, g1, b1 = color_rgb
|
||||
else:
|
||||
return 1
|
||||
r2, g2, b2 = _rgb
|
||||
|
||||
@@ -117,7 +117,7 @@ def compare_images(image1_path, image2_path, **options):
|
||||
similarity_index = ssim(image1_array, image2_array)
|
||||
|
||||
epsilon = 0.01
|
||||
if base_score is None:
|
||||
if base_score is not None:
|
||||
if similarity_index >= base_score + epsilon:
|
||||
return (similarity_index - base_score) / (1 - base_score)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user