110 lines
3.3 KiB
Python
110 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
🧛♂️ GRONK FULL PROCESSING
|
|
Generates a complete sprite sheet for Gronk with background removal.
|
|
Output Format: 5 Rows x 4 Columns
|
|
Row 0: Walk Down (4 frames)
|
|
Row 1: Walk Right (4 frames)
|
|
Row 2: Walk Up (4 frames - note: only 3 source files found, will dup frame 2)
|
|
Row 3: Vape (4 frames)
|
|
Row 4: Idle (3 frames: Down, Right, Up)
|
|
"""
|
|
|
|
import os
|
|
from rembg import remove
|
|
from PIL import Image
|
|
|
|
INPUT_DIR = "assets/slike 🟢/demo 🔴/characters 🔴/gronk"
|
|
OUTPUT_DIR = "assets/characters"
|
|
OUTPUT_SHEET = "gronk_full_sheet.png"
|
|
|
|
# Target frame size
|
|
W, H = 128, 128
|
|
|
|
# File mappings corresponding to rows
|
|
ROWS = [
|
|
# Row 0: Walk Down
|
|
[
|
|
"gronk_walk_down_01_1767408359188.png",
|
|
"gronk_walk_down_02_1767408376011.png",
|
|
"gronk_walk_down_03_1767408392737.png",
|
|
"gronk_walk_down_04_1767408407769.png"
|
|
],
|
|
# Row 1: Walk Right
|
|
[
|
|
"gronk_walk_right_01_1767408494468.png",
|
|
"gronk_walk_right_02_1767408509256.png",
|
|
"gronk_walk_right_03_1767408524931.png",
|
|
"gronk_walk_right_04_1767408540208.png"
|
|
],
|
|
# Row 2: Walk Up (Only 3 files found in list, duplicating middle for 4-frame cycle 1-2-3-2)
|
|
[
|
|
"gronk_walk_up_01_1767408423382.png",
|
|
"gronk_walk_up_02_1767408438192.png",
|
|
"gronk_walk_up_03_1767408452582.png",
|
|
"gronk_walk_up_02_1767408438192.png" # Duplicate for loop
|
|
],
|
|
# Row 3: Vape
|
|
[
|
|
"gronk_vape_01_1767408553955.png",
|
|
"gronk_vape_02_1767408567935.png",
|
|
"gronk_vape_03_1767408582938.png",
|
|
"gronk_vape_04_1767408599735.png"
|
|
],
|
|
# Row 4: Idle (Down, Right, Up) + 1 Empty
|
|
[
|
|
"gronk_idle_down_1767408310253.png",
|
|
"gronk_idle_right_1767408343383.png",
|
|
"gronk_idle_up_1767408324452.png",
|
|
None # Empty slot
|
|
]
|
|
]
|
|
|
|
def main():
|
|
print("🧛♂️ PROCESSING GRONK FULL SHEET...")
|
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
|
|
|
# Create master sheet
|
|
sheet_width = W * 4
|
|
sheet_height = H * 5
|
|
full_sheet = Image.new("RGBA", (sheet_width, sheet_height))
|
|
|
|
for row_idx, file_list in enumerate(ROWS):
|
|
print(f" 📌 Processing Row {row_idx}...")
|
|
for col_idx, filename in enumerate(file_list):
|
|
if not filename:
|
|
continue
|
|
|
|
path = os.path.join(INPUT_DIR, filename)
|
|
if not os.path.exists(path):
|
|
print(f" ❌ File not found: {filename}")
|
|
continue
|
|
|
|
# Process Image
|
|
try:
|
|
img = Image.open(path)
|
|
|
|
# 1. Remove Background
|
|
img = remove(img)
|
|
|
|
# 2. Resize
|
|
img = img.resize((W, H), Image.LANCZOS)
|
|
|
|
# 3. Paste into sheet
|
|
x = col_idx * W
|
|
y = row_idx * H
|
|
full_sheet.paste(img, (x, y))
|
|
print(f" ✅ Placed {filename} at ({x}, {y})")
|
|
|
|
except Exception as e:
|
|
print(f" ⚠️ Error processing {filename}: {e}")
|
|
|
|
# Save
|
|
out_path = os.path.join(OUTPUT_DIR, OUTPUT_SHEET)
|
|
full_sheet.save(out_path)
|
|
print(f"✨ Saved FULL spritesheet to: {out_path}")
|
|
print(f" Size: {sheet_width}x{sheet_height}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|