Files
novafarma/scripts/resize_to_32px.py
David Kotnik 305c915fc7 🇸🇮 Kompletna reorganizacija v slovensko strukturo
 NAREJENO:
- Scan 1,112 PNG datotek
- Najdenih 109 duplikatov (preskočenih)
- Premaknjenih 635 aktivnih assetov v slovensko strukturo
- Izbrisanih 14 starih angleških map
- Updatanih 11 scriptov za nove poti

📁 NOVA STRUKTURA:
assets/slike/
├── liki/ (karakterji: Kai, Gronk, Ana, NPCs)
├── sovrazniki/ (zombiji, mutanti, bossi)
├── biomi/ (18 zon)
├── zgradbe/ (vse stavbe in props)
├── predmeti/ (orodja, semena, hrana)
├── orozje/ (hladno, strelno)
├── rastline/ (posevki, drevesa)
├── ui/ (interface elementi)
├── efekti/ (voda, dim)
└── cutscene/ (flashbacki)

💡 ADHD-FRIENDLY:
- Slovensko poimenovanje
- Max 2 nivoja podmap
- Logična kategorizacija
- Enostavno iskanje
2025-12-31 01:54:16 +01:00

120 lines
3.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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/slike')
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/slike_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()