Moving from matplotlib to pillow for score

This commit is contained in:
2026-03-15 23:57:14 +01:00
parent f43c296e8a
commit e703662d9e
3 changed files with 7 additions and 8 deletions
+3 -4
View File
@@ -103,6 +103,8 @@ import io
import shutil
from pdf2image import convert_from_path
from PIL import Image, ImageDraw, ImageFont
import matplotlib
matplotlib.use('Agg') # Force headless rendering
import matplotlib.pyplot as plt
# plt.rcParams.update({ "text.usetex": True,
@@ -302,8 +304,6 @@ def color(score):
def render_score_text(label, score, error, width_px, fontsize=18,
bg_color=(255, 255, 255, 255),
with_error=True, id=None):
# 1. Calculate Color Gradient
# 2. Build highlight-text String & Properties
# Wrap colored parts in < >
score_str = f"{label} Note : <{score}>"
@@ -321,8 +321,6 @@ def render_score_text(label, score, error, width_px, fontsize=18,
fig_width = width_px / dpi
chars_per_line = int(fig_width * 10)
# wrapped_text = textwrap.fill(score_str, width=chars_per_line)
# fig_height = 0.4 + 0.2
fig_height = 0.8
@@ -561,6 +559,7 @@ def process_student(student_id, labels_data, root_dir, all_labels, overwrite):
def process_correction(root_dir, data, all_labels, overwrite=False):
# with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
# # Create a list of futures
# futures = []