initial commit

This commit is contained in:
2026-07-16 14:26:42 +02:00
commit 1cffdab768
7 changed files with 125 additions and 0 deletions

5
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

10
.idea/Labels.iml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.12 (Labels)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (Labels)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Labels)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Labels.iml" filepath="$PROJECT_DIR$/.idea/Labels.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

83
main.py Normal file
View File

@@ -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}")