#!/usr/bin/env python3 """ 创建简单的Logo占位符图片 需要安装PIL/Pillow: pip install Pillow """ from PIL import Image, ImageDraw, ImageFont import os def create_gsszyy_logo(): """创建甘肃省中医院Logo""" # 创建图片 img = Image.new('RGB', (400, 200), color='#667eea') draw = ImageDraw.Draw(img) # 尝试使用系统字体,如果失败则使用默认字体 try: font = ImageFont.truetype("/System/Library/Fonts/PingFang.ttc", 60) font_small = ImageFont.truetype("/System/Library/Fonts/PingFang.ttc", 30) except: font = ImageFont.load_default() font_small = ImageFont.load_default() # 绘制文字 text = "中医院" text2 = "甘肃省中医院" # 计算文字位置(居中) bbox = draw.textbbox((0, 0), text, font=font) text_width = bbox[2] - bbox[0] text_height = bbox[3] - bbox[1] position = ((400 - text_width) // 2, (200 - text_height) // 2 - 10) bbox2 = draw.textbbox((0, 0), text2, font=font_small) text_width2 = bbox2[2] - bbox2[0] position2 = ((400 - text_width2) // 2, position[1] + 70) # 绘制 draw.text(position, text, fill='white', font=font) draw.text(position2, text2, fill='white', font=font_small) # 保存 img.save('frontend/public/logo-gsszyy.jpg') print("已创建: frontend/public/logo-gsszyy.jpg") def create_square_logo(): """创建方形Logo""" # 创建图片(正方形) img = Image.new('RGB', (200, 200), color='#667eea') draw = ImageDraw.Draw(img) # 尝试使用系统字体 try: font = ImageFont.truetype("/System/Library/Fonts/PingFang.ttc", 100) except: font = ImageFont.load_default() # 绘制文字 text = "中" bbox = draw.textbbox((0, 0), text, font=font) text_width = bbox[2] - bbox[0] text_height = bbox[3] - bbox[1] position = ((200 - text_width) // 2, (200 - text_height) // 2) draw.text(position, text, fill='white', font=font) # 保存 img.save('frontend/public/logo.jpg') print("已创建: frontend/public/logo.jpg") if __name__ == '__main__': print("开始创建Logo占位符...") create_gsszyy_logo() create_square_logo() print("完成!")