SESSION END 23:40 - Complete visual overhaul. New folder structure (Ground/Veg/Env). Generated final assets (Style 32 Dark-Chibi). Implemented GrassScene_Clean.js with density logic. Scene PERFECT.
This commit is contained in:
18
scripts/utils/resize_image.py
Normal file
18
scripts/utils/resize_image.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from PIL import Image
|
||||
import sys
|
||||
import os
|
||||
|
||||
def resize_image(image_path, size):
|
||||
try:
|
||||
img = Image.open(image_path)
|
||||
img = img.resize((size, size), Image.Resampling.LANCZOS)
|
||||
img.save(image_path)
|
||||
print(f"Resized {image_path} to {size}x{size}")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: python resize.py <path> <size>")
|
||||
else:
|
||||
resize_image(sys.argv[1], int(sys.argv[2]))
|
||||
35
scripts/utils/single_rembg.py
Normal file
35
scripts/utils/single_rembg.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import sys
|
||||
import os
|
||||
from rembg import remove
|
||||
from PIL import Image
|
||||
|
||||
def process_file(file_path):
|
||||
print(f"Processing: {file_path}")
|
||||
try:
|
||||
if not os.path.exists(file_path):
|
||||
print(f"Error: File {file_path} not found.")
|
||||
return
|
||||
|
||||
with open(file_path, "rb") as input_file:
|
||||
input_data = input_file.read()
|
||||
|
||||
output_data = remove(input_data)
|
||||
|
||||
# Save as png (force extension if needed)
|
||||
output_path = os.path.splitext(file_path)[0] + ".png"
|
||||
|
||||
with open(output_path, "wb") as output_file:
|
||||
output_file.write(output_data)
|
||||
|
||||
print(f"Success! Saved to {output_path}")
|
||||
|
||||
except ImportError:
|
||||
print("Error: Required libraries (rembg, PIL) not found. Please install them.")
|
||||
except Exception as e:
|
||||
print(f"Error processing file: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python single_rembg.py <image_path>")
|
||||
else:
|
||||
process_file(sys.argv[1])
|
||||
Reference in New Issue
Block a user