Spaces:
Sleeping
Sleeping
File size: 2,978 Bytes
b6de031 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
"""
Generate static sample images for the Handwriting Assessment App
"""
from PIL import Image, ImageDraw, ImageFont
def create_sample_answer_key_image():
"""Create a sample answer key image optimized for gemini3n series (768x768)."""
img_width, img_height = 768, 768
img = Image.new('RGB', (img_width, img_height), color='white')
draw = ImageDraw.Draw(img)
# Use default font to avoid font loading issues
try:
font_large = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 40)
font_medium = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 35)
except:
font_large = ImageFont.load_default()
font_medium = ImageFont.load_default()
# Sample answer key content
lines = [
("Question 1: What is the capital of France?", font_medium),
("Answer: Paris", font_large),
("", font_medium),
("Question 2: Calculate 15 + 27", font_medium),
("Answer: 42", font_large),
("", font_medium),
("Question 3: Name three primary colors", font_medium),
("Answer: Red, Blue, Yellow", font_large)
]
y_position = 80
for line_text, font in lines:
if line_text:
x_offset = 60
draw.text((x_offset, y_position), line_text, fill='black', font=font)
y_position += 80
return img
def create_sample_student_response_image():
"""Create a sample student response image optimized for gemini3n series (768x768)."""
img_width, img_height = 768, 768
img = Image.new('RGB', (img_width, img_height), color='white')
draw = ImageDraw.Draw(img)
try:
font_large = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 40)
font_medium = ImageFont.truetype("/System/Library/Fonts/Arial.ttf", 35)
except:
font_large = ImageFont.load_default()
font_medium = ImageFont.load_default()
# Student response with slight variations
lines = [
("Question 1: What is the capital of France?", font_medium),
("Answer: Paris", font_large),
("", font_medium),
("Question 2: Calculate 15 + 27", font_medium),
("Answer: 42", font_large),
("", font_medium),
("Question 3: Name three primary colors", font_medium),
("Answer: Red, Blue, Yellow", font_large)
]
y_position = 80
for line_text, font in lines:
if line_text:
x_offset = 65
draw.text((x_offset, y_position), line_text, fill='black', font=font)
y_position += 80
return img
if __name__ == "__main__":
# Generate and save sample images
answer_key_img = create_sample_answer_key_image()
answer_key_img.save("sample_answer_key.png")
print("Created sample_answer_key.png")
student_response_img = create_sample_student_response_image()
student_response_img.save("sample_student_response.png")
print("Created sample_student_response.png") |