49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
def main():
|
|
if len(sys.argv) != 3:
|
|
print("Uso: python3 rgbify_batch.py <input_dir> <output_dir>")
|
|
sys.exit(1)
|
|
|
|
input_dir = sys.argv[1]
|
|
output_dir = sys.argv[2]
|
|
|
|
if not os.path.isdir(input_dir):
|
|
print(f"Errore: directory di input non trovata: {input_dir}")
|
|
sys.exit(1)
|
|
|
|
os.makedirs(output_dir, exist_ok=True)
|
|
|
|
# Scansiona tutti i .tif nella directory di input
|
|
for filename in os.listdir(input_dir):
|
|
if not filename.lower().endswith(".tif"):
|
|
continue
|
|
|
|
in_path = os.path.join(input_dir, filename)
|
|
out_name = filename.replace(".tif", "_rgb.tif")
|
|
out_path = os.path.join(output_dir, out_name)
|
|
|
|
print(f"[PROCESS] {filename} → {out_name}")
|
|
|
|
cmd = [
|
|
"rio", "rgbify",
|
|
"-b", "-10000",
|
|
"-i", "0.1",
|
|
in_path,
|
|
out_path
|
|
]
|
|
|
|
try:
|
|
subprocess.run(cmd, check=True)
|
|
print(f"[OK] {out_name}")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"[ERROR] {filename}: {e}")
|
|
|
|
print("Completato.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|