From 1cffdab768d8d657b1ce7ca9f4fe229ac85ef890 Mon Sep 17 00:00:00 2001 From: lucas_csr Date: Thu, 16 Jul 2026 14:26:42 +0200 Subject: [PATCH] initial commit --- .idea/.gitignore | 5 ++ .idea/Labels.iml | 10 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ main.py | 83 +++++++++++++++++++ 7 files changed, 125 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Labels.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 main.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Labels.iml b/.idea/Labels.iml new file mode 100644 index 0000000..9ec1577 --- /dev/null +++ b/.idea/Labels.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f32c64d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0339e46 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..f6b1189 --- /dev/null +++ b/main.py @@ -0,0 +1,83 @@ +from PIL import Image, ImageDraw, ImageFont +import os + +# ========================== +# Settings +# ========================== + +START_NUMBER = 3398 # First number +NUM_PAGES = 9 # Number of pages to generate + +ROWS = 8 +COLS = 3 + +# A4 at 300 DPI +PAGE_WIDTH = 2480 +PAGE_HEIGHT = 3508 + +MARGIN_X = 0 +MARGIN_Y = 0 + +OUTPUT_FOLDER = "output" + +# Font +FONT_SIZE = 80 + +# Optional: use your own TTF font +FONT_PATH = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" +# FONT_PATH = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" + +# ========================== + +os.makedirs(OUTPUT_FOLDER, exist_ok=True) + +try: + font = ImageFont.truetype(FONT_PATH, FONT_SIZE) +except OSError: + print("Font not found. Using default font.") + font = ImageFont.load_default() + +usable_width = PAGE_WIDTH - 2 * MARGIN_X +usable_height = PAGE_HEIGHT - 2 * MARGIN_Y + +cell_width = usable_width / COLS +cell_height = usable_height / ROWS + +current = START_NUMBER +current_start = START_NUMBER +current_end = START_NUMBER + +for page in range(NUM_PAGES): + + current_start = current -1 + image = Image.new("RGB", (PAGE_WIDTH, PAGE_HEIGHT), "white") + draw = ImageDraw.Draw(image) + + for row in range(ROWS): + for col in range(COLS): + + number = f"{current:04d}" + + left = MARGIN_X + col * cell_width + top = MARGIN_Y + row * cell_height + + bbox = draw.textbbox((0, 0), number, font=font) + text_width = bbox[2] - bbox[0] + text_height = bbox[3] - bbox[1] + + x = left + (cell_width - text_width) / 2 + y = top + (cell_height - text_height) / 2 + + draw.text((x, y), number, fill="black", font=font) + + current += 1 + current_end = current -2 + filename = os.path.join( + OUTPUT_FOLDER, + #f"numbers_page_{page + 1:03d}.png" + f"{current_start+ 1:04d}-{current_end+1:04d}.png" + ) + image.save(filename) + +print(f"Generated {NUM_PAGES} page(s).") +print(f"Last number: {current - 1:04d}") \ No newline at end of file