Divers, en lien avec DMI04 (gemini_for_enonce.py, smaller images, link to enonce.pdf)
This commit is contained in:
+15
-2
@@ -396,6 +396,8 @@ def render_score_text(label, score, error, width_px, fontsize=30,
|
||||
|
||||
return img
|
||||
|
||||
A4_WIDTH_200DPI = 1654
|
||||
TARGET_MIN_WIDTH = int(A4_WIDTH_200DPI * 0.9) # 1406 pixels
|
||||
def compose_label_image(base_img, label, result, hmin,
|
||||
render_fn=render_real_latex_text,
|
||||
draw_callback=None,
|
||||
@@ -415,6 +417,17 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
draw_callback: Optional function(type, draw_obj, position_dict, data_dict)
|
||||
called when elements are placed. Used for checkboxes.
|
||||
"""
|
||||
|
||||
left_pad = 0
|
||||
if base_img.width < TARGET_MIN_WIDTH:
|
||||
total_missing = TARGET_MIN_WIDTH - base_img.width
|
||||
left_pad = min(total_missing, MARGIN_LEFT)
|
||||
right_pad = total_missing - left_pad
|
||||
|
||||
new_base = Image.new("RGB", (TARGET_MIN_WIDTH, base_img.height), "white")
|
||||
new_base.paste(base_img, (left_pad, 0))
|
||||
base_img = new_base
|
||||
|
||||
score = result.get('score', 0)
|
||||
error = result.get('error', "")
|
||||
feedbacks = result.get('feedback', [])
|
||||
@@ -485,8 +498,8 @@ def compose_label_image(base_img, label, result, hmin,
|
||||
|
||||
target_ymin = (ymin - hmin) + image_offset_y
|
||||
target_ymax = (ymax - hmin) + image_offset_y
|
||||
target_xmin = xmin + MARGIN_LEFT
|
||||
target_xmax = xmax + MARGIN_LEFT
|
||||
target_xmin = xmin + MARGIN_LEFT + left_pad
|
||||
target_xmax = xmax + MARGIN_LEFT + left_pad
|
||||
|
||||
# Draw Rectangle (if not suppressed)
|
||||
if "norectangle" not in fb:
|
||||
|
||||
Reference in New Issue
Block a user