Applied green screen background (#00FF00) to all game assets using rembg AI - ready for chroma keying
This commit is contained in:
88
scripts/test_first_5_green.py
Normal file
88
scripts/test_first_5_green.py
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
TEST: First 5 images to green screen
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from rembg import remove
|
||||
from PIL import Image
|
||||
|
||||
# Find first 5 images
|
||||
all_images = []
|
||||
for dir_path in ["assets/PHASE_PACKS/0_DEMO", "assets/PHASE_PACKS/1_FAZA_1"]:
|
||||
if Path(dir_path).exists():
|
||||
all_images.extend(Path(dir_path).rglob("*.png"))
|
||||
|
||||
# Take first 5
|
||||
test_images = sorted([str(p) for p in all_images if '_backup' not in str(p)])[:5]
|
||||
|
||||
OUTPUT_DIR = "test_5_green"
|
||||
CHROMA_GREEN = (0, 255, 0, 255)
|
||||
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
|
||||
print("🟢 TEST: First 5 images → Green Screen")
|
||||
print("=" * 50)
|
||||
|
||||
results = []
|
||||
|
||||
for i, img_path in enumerate(test_images):
|
||||
name = os.path.basename(img_path)
|
||||
print(f"\n[{i+1}/5] Processing: {name}")
|
||||
|
||||
# Open and process
|
||||
img = Image.open(img_path)
|
||||
img_no_bg = remove(img)
|
||||
|
||||
# Create green background version
|
||||
green_bg = Image.new('RGBA', img_no_bg.size, CHROMA_GREEN)
|
||||
green_bg.paste(img_no_bg, (0, 0), img_no_bg)
|
||||
green_rgb = green_bg.convert('RGB')
|
||||
|
||||
# Save
|
||||
out_name = f"{i+1}_{name}"
|
||||
green_rgb.save(os.path.join(OUTPUT_DIR, out_name), 'PNG')
|
||||
|
||||
results.append({'name': name, 'out': out_name, 'path': img_path})
|
||||
print(f" ✅ Saved: {out_name}")
|
||||
|
||||
# Create simple HTML
|
||||
html = '''<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test 5 Green</title>
|
||||
<style>
|
||||
body { background: #1a1a2e; color: white; font-family: Arial; padding: 30px; }
|
||||
h1 { color: #00ff00; text-align: center; }
|
||||
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; margin-top: 30px; }
|
||||
.card { text-align: center; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 10px; }
|
||||
.card img { max-width: 200px; max-height: 200px; border-radius: 8px; }
|
||||
.card .name { font-size: 0.8em; color: #aaa; margin-top: 10px; word-break: break-all; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🟢 Test: First 5 Images with Green Background</h1>
|
||||
<div class="grid">
|
||||
'''
|
||||
|
||||
for r in results:
|
||||
html += f'''
|
||||
<div class="card">
|
||||
<img src="{r['out']}" alt="{r['name']}">
|
||||
<div class="name">{r['name']}</div>
|
||||
</div>
|
||||
'''
|
||||
|
||||
html += '''
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
|
||||
with open(os.path.join(OUTPUT_DIR, "index.html"), 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print(f"✅ Done! Open: {OUTPUT_DIR}/index.html")
|
||||
Reference in New Issue
Block a user