commit e1ad364124ffbb8a90cca63ebfc28f0886de5878 Author: Daniel Nagel Date: Sat Jan 3 00:05:18 2026 +0100 Init Commit diff --git a/areno_map.png b/areno_map.png new file mode 100644 index 0000000..6e49f8e Binary files /dev/null and b/areno_map.png differ diff --git a/export_tiles.bat b/export_tiles.bat new file mode 100644 index 0000000..31d9722 --- /dev/null +++ b/export_tiles.bat @@ -0,0 +1,3 @@ +@echo off +python tile_exporter.py +pause \ No newline at end of file diff --git a/tile_exporter.py b/tile_exporter.py new file mode 100644 index 0000000..d7e7fc4 --- /dev/null +++ b/tile_exporter.py @@ -0,0 +1,55 @@ +from PIL import Image +import os +import math + +Image.MAX_IMAGE_PIXELS = None # Schutz bei großen Bildern deaktivieren + +# === KONFIGURATION === +image_path = "areno_map.png" # Pfad zur großen Karte +output_dir = "tiles" # Zielverzeichnis für die Tiles +tile_size = 256 # Größe eines Tiles +max_zoom = 7 # Zoom-Stufen 0–7 + +def generate_leaflet_tiles(image_path, output_dir, tile_size=256, max_zoom=7): + original = Image.open(image_path) + orig_width, orig_height = original.size + + for z in range(max_zoom + 1): + scale = 2 ** (max_zoom - z) + width = math.ceil(orig_width / scale) + height = math.ceil(orig_height / scale) + + # Kein Resize bei maximaler Zoomstufe (Originalgröße) + if z == max_zoom: + resized = original + else: + resized = original.resize((width, height), Image.Resampling.LANCZOS) + + tiles_x = math.ceil(width / tile_size) + tiles_y = math.ceil(height / tile_size) + + offset_x = tiles_x // 2 + offset_y = tiles_y // 2 + + for x in range(tiles_x): + for y in range(tiles_y): + left = x * tile_size + upper = y * tile_size + right = min(left + tile_size, width) + lower = min(upper + tile_size, height) + + tile = resized.crop((left, upper, right, lower)) + + tile_x = x - offset_x + tile_y = y - offset_y + + dir_path = os.path.join(output_dir, str(z), str(tile_x)) + os.makedirs(dir_path, exist_ok=True) + tile_path = os.path.join(dir_path, f"{tile_y}.png") + tile.save(tile_path) + + print(f"✅ Zoom {z} fertig – {tiles_x}×{tiles_y} Tiles") + + print("🎉 Alle Tiles erfolgreich generiert.") + +generate_leaflet_tiles(image_path, output_dir, tile_size, max_zoom)