Add bearbeite_fotos_farben.py for post-Upscayl color correction
This commit is contained in:
1 parent
75795eaa74
commit
b080660188
1 file changed
+58
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
from PIL import Image, ImageEnhance, ImageOps
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
# Hier kommen die Bilder rein, nachdem Upscayl sie entrauscht und vergrößert hat
|
||||
INPUT_DIR = os.path.join(BASE_DIR, 'media', 'Schnappix_Upscayl')
|
||||
# Hier landen die fertigen Hochzeitsbilder
|
||||
OUTPUT_DIR = os.path.join(BASE_DIR, 'media', 'Schnappix_Final')
|
||||
|
||||
def process_colors():
|
||||
if not os.path.exists(INPUT_DIR):
|
||||
print(f"Fehler: Der Ordner '{INPUT_DIR}' existiert noch nicht.")
|
||||
print("Bitte lass zuerst Upscayl laufen und speichere die Bilder dort ab!")
|
||||
return
|
||||
|
||||
if not os.path.exists(OUTPUT_DIR):
|
||||
os.makedirs(OUTPUT_DIR)
|
||||
print(f"Zielordner erstellt: {OUTPUT_DIR}")
|
||||
|
||||
processed_count = 0
|
||||
|
||||
for filename in os.listdir(INPUT_DIR):
|
||||
if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')):
|
||||
input_path = os.path.join(INPUT_DIR, filename)
|
||||
output_path = os.path.join(OUTPUT_DIR, filename)
|
||||
|
||||
if os.path.exists(output_path):
|
||||
continue
|
||||
|
||||
try:
|
||||
with Image.open(input_path) as img:
|
||||
# Der bewährte Farb- und Kontrast-Mix (Option 1 + 4)
|
||||
|
||||
# 1. Auto-Kontrast (Entfernt den Grauschleier)
|
||||
img_step1 = ImageOps.autocontrast(img, cutoff=1)
|
||||
|
||||
# 2. Ganz leichte Aufhellung
|
||||
img_step2 = ImageEnhance.Brightness(img_step1).enhance(1.08)
|
||||
|
||||
# 3. Farbe sanft anheben (um 20%)
|
||||
img_final = ImageEnhance.Color(img_step2).enhance(1.2)
|
||||
|
||||
# Speichern
|
||||
img_final.save(output_path, quality=95)
|
||||
print(f"Farben optimiert: {filename}")
|
||||
processed_count += 1
|
||||
except Exception as e:
|
||||
print(f"Fehler bei {filename}: {e}")
|
||||
|
||||
if processed_count > 0:
|
||||
print(f"\nPerfekt! {processed_count} Bilder haben jetzt starke Farben und tollen Kontrast.")
|
||||
print(f"Die fertigen Hochzeitsbilder liegen in: {OUTPUT_DIR}")
|
||||
else:
|
||||
print("\nKeine neuen Bilder zum Bearbeiten gefunden.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Starte Farb- und Kontrastoptimierung für Upscayl-Bilder...")
|
||||
process_colors()
|
||||
Reference in new issue
Block a user