This commit is contained in:
2025-12-30 23:48:51 +01:00
parent a072fd48b1
commit 190d45edfa
399 changed files with 3914 additions and 1 deletions

119
scripts/resize_to_32px.py Normal file
View File

@@ -0,0 +1,119 @@
#!/usr/bin/env python3
"""
Resize to PROPER INDIE GAME sizes - 32x32 standard!
"""
import os
from pathlib import Path
from PIL import Image
# CORRECT sizes for indie games
RESIZE_CONFIG = {
'terrain': 32, # 32x32 tiles (Stardew Valley standard!)
'crops': 32, # 32x32 tiles
'buildings': 32, # 32x32
'items': 16, # 16x16 for inventory items (smaller!)
'ui': None, # Keep original
'effects': 24, # 24x24 for effects
'environment': { # Variable sizes
'campfire': 32,
'dead_tree': (32, 48), # Tall sprite
'rock': (24, 16) # Wide sprite
},
'characters': 32, # 32x32 for characters
'enemies': 32 # 32x32 for enemies
}
def resize_image(input_path: Path, output_path: Path, size):
"""Resize image maintaining quality"""
try:
img = Image.open(input_path)
if size is None:
if input_path != output_path:
img.save(output_path, 'PNG')
return True
if isinstance(size, tuple):
resized = img.resize(size, Image.Resampling.LANCZOS)
else:
resized = img.resize((size, size), Image.Resampling.LANCZOS)
resized.save(output_path, 'PNG', optimize=True)
print(f"{output_path.name}: {img.size}{resized.size}")
return True
except Exception as e:
print(f"{input_path.name}: {e}")
return False
def get_target_size(category: str, filename: str):
"""Determine target size"""
config = RESIZE_CONFIG.get(category)
if config is None:
return None
if isinstance(config, dict):
for key, size in config.items():
if key in filename:
return size
return 32 # Default
return config
def resize_category(base_dir: Path, category: str):
"""Resize all images in category"""
category_path = base_dir / category
if not category_path.exists():
return 0
print(f"\n📁 {category}/")
png_files = list(category_path.glob('*.png'))
if not png_files:
return 0
count = 0
for png_file in png_files:
size = get_target_size(category, png_file.stem)
if resize_image(png_file, png_file, size):
count += 1
return count
def main():
print("=" * 60)
print("🎮 RESIZING TO PROPER INDIE GAME SIZES (32×32 STANDARD)")
print("=" * 60)
demo_dir = Path('assets/images/demo')
print(f"\n📦 Transparent assets: {demo_dir}")
total = 0
for category in RESIZE_CONFIG.keys():
if category != 'environment':
total += resize_category(demo_dir, category)
total += resize_category(demo_dir, 'environment')
orig_dir = Path('assets/images/demo_originals_with_white_bg')
if orig_dir.exists():
print(f"\n📦 White BG originals: {orig_dir}")
for category in RESIZE_CONFIG.keys():
if category != 'environment':
total += resize_category(orig_dir, category)
total += resize_category(orig_dir, 'environment')
print("\n" + "=" * 60)
print(f"✅ DONE! Resized {total} images to 32×32 standard!")
print("=" * 60)
print("\n🎮 Perfect for indie games like Stardew Valley!")
if __name__ == "__main__":
main()