This commit is contained in:
HuangHai
2026-01-16 22:43:24 +08:00
parent 645e663345
commit 0588ebfa76
2 changed files with 18 additions and 6 deletions

View File

@@ -154,14 +154,26 @@ class ReadImageKit:
if result.get("has_ad") and result.get("close_point") and len(result.get("close_point")) == 2:
norm_point = result["close_point"]
x = int(norm_point[0] / 1000 * primary_width)
y = int(norm_point[1] / 1000 * primary_height)
norm_x, norm_y = norm_point
ad_type = result.get("ad_type", "unknown")
if ad_type == "rabbit":
offset_y = int(primary_height * 0.05)
offset_x = int(primary_width * 0.014)
y = min(primary_height - 1, y + offset_y)
x = min(primary_width - 1, x + offset_x)
ratio_x = norm_x / 1000.0
if ratio_x > 0.7:
x = int(primary_width * 0.88)
y = int(primary_height * 0.83)
logger.info("采用右侧浮动广告固定坐标关闭按钮 (0.88W, 0.83H)")
else:
x = int(norm_x / 1000 * primary_width)
y = int(norm_y / 1000 * primary_height)
offset_y = int(primary_height * 0.05)
offset_x = int(primary_width * 0.014)
y = min(primary_height - 1, y + offset_y)
x = min(primary_width - 1, x + offset_x)
else:
x = int(norm_x / 1000 * primary_width)
y = int(norm_y / 1000 * primary_height)
try:
os.makedirs(TEMP_IMAGE_DIR, exist_ok=True)
img = Image.open(image_path).convert("RGB")