Update bearbeite_fotos_farben.py to process NextGenUp output and convert to JPG
This commit is contained in:
1 parent
d82902641e
commit
4cd886b696
1 file changed
+19
-12
+19
-12
@@ -2,15 +2,15 @@ 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')
|
||||
|
||||
# Neuer Input Ordner von nextgenUp
|
||||
INPUT_DIR = os.path.join(BASE_DIR, 'media', '20260919_HochzeitNeleTill_NextGenUp')
|
||||
# Neuer Output Ordner für die komplett fertigen Hochzeitsbilder
|
||||
OUTPUT_DIR = os.path.join(BASE_DIR, 'media', '20260919_HochzeitNeleTill_Final_Colors')
|
||||
|
||||
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!")
|
||||
print(f"Fehler: Der Ordner '{INPUT_DIR}' existiert nicht.")
|
||||
return
|
||||
|
||||
if not os.path.exists(OUTPUT_DIR):
|
||||
@@ -24,13 +24,17 @@ def process_colors():
|
||||
input_path = os.path.join(INPUT_DIR, filename)
|
||||
output_path = os.path.join(OUTPUT_DIR, filename)
|
||||
|
||||
# Wenn die fertige Datei schon existiert, überspringen
|
||||
if os.path.exists(output_path):
|
||||
continue
|
||||
|
||||
try:
|
||||
# Wir öffnen das Bild mit RGBA (falls es von NextGenUp als PNG kommt)
|
||||
with Image.open(input_path) as img:
|
||||
# Der bewährte Farb- und Kontrast-Mix (Option 1 + 4)
|
||||
|
||||
# Falls es einen Alpha-Kanal hat (PNG), konvertieren wir es zu RGB, um Fehler zu vermeiden
|
||||
if img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info):
|
||||
img = img.convert('RGB')
|
||||
|
||||
# 1. Auto-Kontrast (Entfernt den Grauschleier)
|
||||
img_step1 = ImageOps.autocontrast(img, cutoff=1)
|
||||
|
||||
@@ -40,9 +44,12 @@ def process_colors():
|
||||
# 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}")
|
||||
# Speichern (als PNG, da der Input PNG war, oder als JPG. Hier speichern wir es als das Originalformat)
|
||||
# Um Platz zu sparen und maximale Kompatibilität zu sichern, speichern wir als JPG
|
||||
output_jpg_path = os.path.splitext(output_path)[0] + '.jpg'
|
||||
img_final.save(output_jpg_path, 'JPEG', quality=95)
|
||||
|
||||
print(f"Farben optimiert: {filename} -> JPG")
|
||||
processed_count += 1
|
||||
except Exception as e:
|
||||
print(f"Fehler bei {filename}: {e}")
|
||||
@@ -54,5 +61,5 @@ def process_colors():
|
||||
print("\nKeine neuen Bilder zum Bearbeiten gefunden.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Starte Farb- und Kontrastoptimierung für Upscayl-Bilder...")
|
||||
print("Starte Farb- und Kontrastoptimierung für NextGenUp-Bilder...")
|
||||
process_colors()
|
||||
Reference in new issue
Block a user