from PIL import Image
import pytesseract

path = '/root/.hermes/cache/images/img_668b1b2125b9.jpg'
img = Image.open(path)

# 只放大1.5倍，用chi_sim
img_large = img.resize((int(img.width * 1.5), int(img.height * 1.5)), Image.LANCZOS)

text = pytesseract.image_to_string(img_large, lang='chi_sim', config='--psm 4')
print("=== 全图 ===")
print(text.strip()[:2000])

# 分区域识别
width, height = img.size
# 上半部分
top = img.crop((0, 0, width, height//2))
top_text = pytesseract.image_to_string(top.resize((top.width*2, top.height*2), Image.LANCZOS), lang='chi_sim', config='--psm 6')
print("\n=== 上半部分 ===")
print(top_text.strip()[:1500])

# 下半部分
bottom = img.crop((0, height//2, width, height))
bottom_text = pytesseract.image_to_string(bottom.resize((bottom.width*2, bottom.height*2), Image.LANCZOS), lang='chi_sim', config='--psm 6')
print("\n=== 下半部分 ===")
print(bottom_text.strip()[:1500])
