Skip to content

Commit 4f54c87

Browse files
build: automatically add p2ce overlay to addon thumbnails
1 parent 5b40dc5 commit 4f54c87

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

_build/assets/thumb_overlay.png

21.2 KB
Loading

_build/build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
import shutil
33
import sys
44

5+
from PIL import Image
56
from sourcepp import vpkpp
67

78

9+
def add_overlay_to_image(base_path: str, overlay_path: str, out_path: str) -> None:
10+
base = Image.open(base_path).convert("RGBA")
11+
overlay = Image.open(overlay_path).convert("RGBA")
12+
base = base.resize(overlay.size, Image.Resampling.BICUBIC)
13+
base.paste(overlay, None, overlay)
14+
base.convert("RGB").save(out_path)
15+
16+
817
def build_addon(addon_dir: str, output_dir_parent: str) -> None:
918
output_dir = os.path.join(output_dir_parent, "p2ce_" + os.path.basename(addon_dir))
1019
os.makedirs(output_dir, exist_ok=True)
@@ -34,6 +43,13 @@ def build_addon(addon_dir: str, output_dir_parent: str) -> None:
3443
vpk.add_entry_from_file(os.path.basename(entry), entry)
3544
vpk.bake()
3645

46+
if (
47+
os.path.exists(thumb_path := os.path.join(output_dir, ".assets", "thumb.png")) or
48+
os.path.exists(thumb_path := os.path.join(output_dir, ".assets", "thumb.jpg")) or
49+
os.path.exists(thumb_path := os.path.join(output_dir, ".assets", "thumb.jpeg"))
50+
):
51+
add_overlay_to_image(thumb_path, os.path.join(os.path.dirname(__file__), "assets", "thumb_overlay.png"), thumb_path)
52+
3753

3854
def zip_addons(parent_dir: str, stem: str) -> None:
3955
print(f"Zipping contents of {parent_dir} into {stem}.zip")

_build/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
pillow==11.3.0
12
sourcepp==2025.9.12

0 commit comments

Comments
 (0)