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:
CalamitousFelicitousness
2026-04-25 23:32:50 +01:00
parent 70630bc6b4
commit bf0f26cad5
+13 -2
View File
@@ -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