chrome (google drive related) + X multi-app examples finished (leaving two emails and thunderbird-profile.tar.gz to be crafted)
This commit is contained in:
@@ -13,6 +13,7 @@ from .docs import is_first_line_centered, check_file_exists, compare_contains_im
|
||||
from .general import check_csv, check_accessibility_tree, run_sqlite3, check_json
|
||||
from .general import exact_match, fuzzy_match, check_include_exclude
|
||||
from .gimp import increase_saturation, decrease_brightness, check_file_exists, compare_triangle_positions
|
||||
from .gimp import compare_images
|
||||
from .libreoffice import check_libre_locale
|
||||
from .pdf import check_pdf_pages
|
||||
from .slides import check_presenter_console_disable, check_image_stretch_and_center, check_slide_numbers_color, \
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import os
|
||||
from typing import List, Union
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
|
||||
def compare_images(pred_img_path_list: Union[str, List[str]], gold_img_path_list: Union[str, List[str]]) -> float:
|
||||
""" Compare two image lists, only if all images are the same, return 1.0, otherwise return 0.0
|
||||
"""
|
||||
if type(pred_img_path_list) != list:
|
||||
pred_img_path_list = [pred_img_path_list]
|
||||
gold_img_path_list = [gold_img_path_list]
|
||||
for pred_img_path, gold_img_path in zip(pred_img_path_list, gold_img_path_list):
|
||||
pred_img = Image.open(pred_img_path)
|
||||
gold_img = Image.open(gold_img_path)
|
||||
diff = ImageChops.difference(pred_img, gold_img)
|
||||
if diff.getbbox():
|
||||
return 0.0
|
||||
return 1.0
|
||||
|
||||
|
||||
def get_gimp_export_path():
|
||||
# Path to GIMP's configuration file. This example assumes GIMP version 2.10.
|
||||
# You need to adjust the path according to the GIMP version and user's file system.
|
||||
|
||||
Reference in New Issue
Block a user