21 lines
610 B
Python
21 lines
610 B
Python
|
|
import cv2
|
|
import numpy as np
|
|
import os
|
|
|
|
def check_icon_brightness(file_path):
|
|
if not os.path.exists(file_path):
|
|
return None
|
|
img = cv2.imread(file_path, cv2.IMREAD_GRAYSCALE)
|
|
if img is None:
|
|
return None
|
|
# 计算非透明区域的平均亮度
|
|
return np.mean(img)
|
|
|
|
icon_dir = r'D:\companyproject\mall\pages\mall\consumer\icons'
|
|
fav = os.path.join(icon_dir, 'favorite.png')
|
|
fav_active = os.path.join(icon_dir, 'favorite-active.png')
|
|
|
|
print(f"favorite.png brightness: {check_icon_brightness(fav)}")
|
|
print(f"favorite-active.png brightness: {check_icon_brightness(fav_active)}")
|