mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
feat(grading): record applied params in postprocess metadata
Color grading mutated pp.image but never wrote to pp.info, so the chosen brightness/contrast/gamma/LUT/etc. were invisible in the saved file's postprocessing/extras chunks and in the live Output panel — unlike every other postprocessor (Upscale, Rembg, NudeNet, PixelArt) which all stamp their settings. Stamp every non-default GradingParams field as 'Grading <name>' so the trail is consistent with the rest of the Process tab. LUT file is recorded by basename rather than full path to keep the metadata string compact.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
from dataclasses import fields
|
||||
from modules import scripts_postprocessing, ui_sections, processing_grading
|
||||
|
||||
|
||||
@@ -12,5 +14,14 @@ class ScriptPostprocessingColorGrading(scripts_postprocessing.ScriptPostprocessi
|
||||
def process(self, pp: scripts_postprocessing.PostprocessedImage, *args, **kwargs): # pylint: disable=arguments-differ
|
||||
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
||||
grading_params = processing_grading.GradingParams(*args, **kwargs)
|
||||
if processing_grading.is_active(grading_params):
|
||||
pp.image = processing_grading.grade_image(pp.image, grading_params)
|
||||
if not processing_grading.is_active(grading_params):
|
||||
return
|
||||
pp.image = processing_grading.grade_image(pp.image, grading_params)
|
||||
defaults = processing_grading.GradingParams()
|
||||
for f in fields(grading_params):
|
||||
val = getattr(grading_params, f.name)
|
||||
if val == getattr(defaults, f.name):
|
||||
continue
|
||||
if f.name == 'lut_cube_file' and val:
|
||||
val = os.path.basename(str(val))
|
||||
pp.info[f"Grading {f.name.replace('_', ' ')}"] = val
|
||||
|
||||
Reference in New Issue
Block a user