61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
import cv2
|
|
import numpy as np
|
|
import os
|
|
import shutil
|
|
|
|
def process_camp_assets():
|
|
# Mappings: Source -> Destination Name
|
|
assets = {
|
|
'assets/references/taborni_ogenj.png': 'campfire.png',
|
|
'assets/references/spalna_vreca.png': 'sleeping_bag.png',
|
|
'assets/references/sotor_zaprt.png': 'tent.png'
|
|
}
|
|
|
|
repo_root = '/Users/davidkotnik/repos/novafarma'
|
|
target_dir_local = os.path.join(repo_root, 'main/assets')
|
|
target_dir_project = '/Users/davidkotnik/nova farma/main/assets'
|
|
|
|
# Ensure dirs exist
|
|
os.makedirs(target_dir_local, exist_ok=True)
|
|
os.makedirs(target_dir_project, exist_ok=True)
|
|
|
|
for src_rel, dest_name in assets.items():
|
|
src_path = os.path.join(repo_root, src_rel)
|
|
if not os.path.exists(src_path):
|
|
print(f"MISSING: {src_path}")
|
|
continue
|
|
|
|
# Load
|
|
img = cv2.imread(src_path, cv2.IMREAD_UNCHANGED)
|
|
if img is None:
|
|
print(f"FAILED TO LOAD: {src_path}")
|
|
continue
|
|
|
|
print(f"Processing {src_rel} (Original: {img.shape})")
|
|
|
|
# Resize logic (Max dim 256 for small items, maybe 300 for tent?)
|
|
# Let's verify size.
|
|
h, w = img.shape[:2]
|
|
max_dim = 256
|
|
if 'sotor' in src_rel: max_dim = 300 # Tent slightly bigger
|
|
|
|
scale = 1.0
|
|
if w > max_dim or h > max_dim:
|
|
scale = max_dim / max(h, w)
|
|
new_w = int(w * scale)
|
|
new_h = int(h * scale)
|
|
img = cv2.resize(img, (new_w, new_h), interpolation=cv2.INTER_AREA)
|
|
|
|
# Save to local repo
|
|
dest_path_local = os.path.join(target_dir_local, dest_name)
|
|
cv2.imwrite(dest_path_local, img)
|
|
print(f"Saved to {dest_path_local} ({img.shape})")
|
|
|
|
# Copy to project folder
|
|
dest_path_project = os.path.join(target_dir_project, dest_name)
|
|
shutil.copy2(dest_path_local, dest_path_project)
|
|
print(f"Synced to {dest_path_project}")
|
|
|
|
if __name__ == "__main__":
|
|
process_camp_assets()
|