From bf0f26cad56a15b583e3e2c3dc8b4412e176c5a7 Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sat, 25 Apr 2026 23:32:50 +0100 Subject: [PATCH] feat(grading): record applied params in postprocess metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ' 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. --- scripts/color_grading.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/color_grading.py b/scripts/color_grading.py index 2e9625981..117961f32 100644 --- a/scripts/color_grading.py +++ b/scripts/color_grading.py @@ -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