71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
🧛♂️ GRONK PROCESSING SCRIPT V2 (RESIZE)
|
|
1. Remove background from vape frames using AI (rembg).
|
|
2. Resize to game-ready size (128x128 per frame).
|
|
3. Create spritesheet (4 frames horizontal).
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from rembg import remove
|
|
from PIL import Image
|
|
|
|
# Input files (found previously)
|
|
INPUT_DIR = "assets/slike 🟢/demo 🔴/characters 🔴/gronk"
|
|
FILES = [
|
|
"gronk_vape_01_1767408553955.png",
|
|
"gronk_vape_02_1767408567935.png",
|
|
"gronk_vape_03_1767408582938.png",
|
|
"gronk_vape_04_1767408599735.png"
|
|
]
|
|
|
|
OUTPUT_DIR = "assets/characters"
|
|
OUTPUT_SHEET = "gronk_sheet.png"
|
|
TARGET_SIZE = (128, 128)
|
|
|
|
def main():
|
|
print("🧛♂️ PROCESSING GRONK (RESIZE)...")
|
|
|
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
|
|
|
processed_images = []
|
|
|
|
# 1. Remove Background & Resize
|
|
print(" 🧹 Removing backgrounds & Resizing...")
|
|
for fname in FILES:
|
|
path = os.path.join(INPUT_DIR, fname)
|
|
if not os.path.exists(path):
|
|
print(f"❌ Missing file: {path}")
|
|
return
|
|
|
|
img = Image.open(path)
|
|
img_clean = remove(img) # AI magic
|
|
img_resized = img_clean.resize(TARGET_SIZE, Image.LANCZOS)
|
|
processed_images.append(img_resized)
|
|
print(f" ✅ Cleaned & Resized {fname}")
|
|
|
|
# 2. Create Spritesheet
|
|
print(" 🎞️ Creating spritesheet...")
|
|
|
|
w, h = TARGET_SIZE
|
|
|
|
# Create strip (4 x 1)
|
|
sheet_width = w * len(processed_images)
|
|
sheet_height = h
|
|
|
|
sheet = Image.new("RGBA", (sheet_width, sheet_height))
|
|
|
|
for i, img in enumerate(processed_images):
|
|
sheet.paste(img, (i * w, 0))
|
|
|
|
output_path = os.path.join(OUTPUT_DIR, OUTPUT_SHEET)
|
|
sheet.save(output_path)
|
|
|
|
print(f" ✨ Saved spritesheet to: {output_path}")
|
|
print(f" Dimensions: {sheet_width}x{sheet_height}")
|
|
print(f" Frame size: {w}x{h}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|