#!/usr/bin/env python3 from PIL import Image, ImageDraw, ImageFont import sys def create_test_image(text, output_path, language='english'): W, H = 1728, 2291 img = Image.new('L', (W, H), 255) draw = ImageDraw.Draw(img) font_path = '/System/Library/Fonts/Helvetica.ttc' try: font = ImageFont.truetype(font_path, 44) except: font = ImageFont.load_default() lines = text.split('\n') y = 100 for line in lines: draw.text((100, y), line, fill=0, font=font) y += 60 img.save(output_path, dpi=(204, 196)) print(f"Test image created: {output_path}") if __name__ == '__main__': if len(sys.argv) < 3: print("Usage: python create_test_image.py ") sys.exit(1) output_path = sys.argv[1] language = sys.argv[2] test_texts = { 'english': """FAX COVER PAGE TO: John Smith FROM: Jane Doe DATE: 2024-01-15 SUBJECT: Meeting Notes PAGES: 5 Dear Mr. Smith, Please review the attached meeting notes before our discussion tomorrow. Best regards, Jane Doe""", 'chinese': """傳真封面頁 收件人:張三 發件人:李四 日期:2024-01-15 主題:業務合作提案 頁數:5 請參閱附件內容,謝謝。 李四""", 'mixed': """FAX COVER PAGE TO: John Smith (張三) FROM: Jane Doe (李四) DATE: 2024-01-15 SUBJECT: Business Proposal (業務提案) PAGES: 5 This fax contains business documents. 請參閱附件內容。 Best regards, Jane Doe""", } text = test_texts.get(language, test_texts['english']) create_test_image(text, output_path, language)