[graphics/krita] libs: Implement commands for setting HDR metadata.

Wolthera van Hövell <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 0cc1804508e8d5626206fe03d7855a7bbcc30370 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 07/08/2026 at 09:24.
Pushed by woltherav into branch 'master'.

Implement commands for setting HDR metadata.

M  +4    -1    libs/command/kis_command_ids.h
M  +3    -0    libs/image/CMakeLists.txt
A  +52   -0    libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.cpp     [License: GPL(v2.0+)]
A  +32   -0    libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.h     [License: GPL(v2.0+)]
A  +53   -0    libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.cpp     [License: GPL(v2.0+)]
A  +32   -0    libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.h     [License: GPL(v2.0+)]
A  +51   -0    libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp     [License: GPL(v2.0+)]
A  +31   -0    libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.h     [License: GPL(v2.0+)]
M  +0    -21   libs/image/kis_image.cc
M  +0    -4    libs/image/kis_image.h
M  +2    -1    libs/image/processing/KisContentLightLevelProcessingVistor.h
M  +2    -2    libs/ui/animation/KisDlgAnimationRenderer.cpp
M  +49   -10   libs/ui/dialogs/kis_dlg_image_properties.cc

https://invent.kde.org/graphics/krita/-/commit/0cc1804508e8d5626206fe03d7855a7bbcc30370

diff --git a/libs/command/kis_command_ids.h b/libs/command/kis_command_ids.h
index b1ae06d3901..5d6725f0084 100644
--- a/libs/command/kis_command_ids.h
+++ b/libs/command/kis_command_ids.h
@@ -44,7 +44,10 @@ enum CommandId {
     KoShapeMergeTextPropertiesCommandId,
     ImageAnimSettingCommandId,
     SvgTextChangeTransformsOnRangeCommandId,
-    SvgTextPathInfoChangeCommandId
+    SvgTextPathInfoChangeCommandId,
+    ChangeImageHdrContentLightLevelId,
+    ChangeImageHdrColorVolumeId,
+    ChangeImageHdrDiffuseWhiteId
 };
 
 }
diff --git a/libs/image/CMakeLists.txt b/libs/image/CMakeLists.txt
index 70fa682c8b2..a9361ee5f5b 100644
--- a/libs/image/CMakeLists.txt
+++ b/libs/image/CMakeLists.txt
@@ -122,6 +122,9 @@ set(kritaimage_LIB_SRCS
    commands_new/KisLazyCreateTransformMaskKeyframesCommand.cpp
    commands_new/KisChangeCloneLayersCommand.cpp
    commands_new/KisLayerCollapseCommand.cpp
+   commands_new/KisChangeImageHdrContentLightLevelCommand.cpp
+   commands_new/KisChangeImageHdrColorVolumeCommand.cpp
+   commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
    processing/kis_do_nothing_processing_visitor.cpp
    processing/kis_simple_processing_visitor.cpp
    processing/kis_convert_color_space_processing_visitor.cpp
diff --git a/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.cpp b/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.cpp
new file mode 100644
index 00000000000..fdcc2f79aec
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.cpp
@@ -0,0 +1,52 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "KisChangeImageHdrColorVolumeCommand.h"
+#include "kis_command_ids.h"
+#include <kis_image.h>
+
+KisChangeImageHdrColorVolumeCommand::KisChangeImageHdrColorVolumeCommand(KisImageWSP image,
+                                                                         std::optional<KisColorVolumeInformation> cvi,
+                                                                         KUndo2Command *parent)
+    : KUndo2Command(kundo2_i18n("Set HDR Color Volume Information"), parent)
+    , m_image(image)
+    , m_cvi(cvi)
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (img) {
+        m_cvi = img->colorVolumeInformation();
+    }
+}
+
+void KisChangeImageHdrColorVolumeCommand::redo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+        img->setColorVolumeInformation(m_cvi);
+
+}
+
+void KisChangeImageHdrColorVolumeCommand::undo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+    img->setColorVolumeInformation(m_oldCvi);
+}
+
+int KisChangeImageHdrColorVolumeCommand::id() const
+{
+    return KisCommandUtils::ChangeImageHdrColorVolumeId;
+}
+
+bool KisChangeImageHdrColorVolumeCommand::mergeWith(const KUndo2Command *otherCommand)
+{
+    const KisChangeImageHdrColorVolumeCommand *other = dynamic_cast<const KisChangeImageHdrColorVolumeCommand *>(otherCommand);
+    if (!other || other->m_image != m_image) return false;
+
+    m_cvi = other->m_cvi;
+    return true;
+}
diff --git a/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.h b/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.h
new file mode 100644
index 00000000000..c0c40809199
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrColorVolumeCommand.h
@@ -0,0 +1,32 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KISCHANGEIMAGEHDRCOLORVOLUMECOMMAND_H
+#define KISCHANGEIMAGEHDRCOLORVOLUMECOMMAND_H
+
+#include <kundo2command.h>
+#include <kis_types.h>
+#include <kis_hdr_metadata.h>
+#include "kritaimage_export.h"
+
+class KRITAIMAGE_EXPORT KisChangeImageHdrColorVolumeCommand : public KUndo2Command
+{
+public:
+    KisChangeImageHdrColorVolumeCommand(KisImageWSP image,
+                                              std::optional<KisColorVolumeInformation> cvi,
+                                              KUndo2Command *parent = nullptr);
+
+    void redo() override;
+    void undo() override;
+
+    int id() const override;
+    bool mergeWith(const KUndo2Command *other) override;
+private:
+    KisImageWSP m_image;
+    std::optional<KisColorVolumeInformation> m_cvi;
+    std::optional<KisColorVolumeInformation> m_oldCvi;
+};
+
+#endif // KISCHANGEIMAGEHDRMETADATACOMMAND_H
diff --git a/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.cpp b/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.cpp
new file mode 100644
index 00000000000..555deb94cf6
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.cpp
@@ -0,0 +1,53 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "KisChangeImageHdrContentLightLevelCommand.h"
+#include "kis_command_ids.h"
+#include <kis_image.h>
+
+KisChangeImageHdrContentLightLevelCommand::KisChangeImageHdrContentLightLevelCommand(KisImageWSP image,
+                                                                   std::optional<KisRelativeContentLightLevelInformation> clli,
+                                                                   KUndo2Command *parent)
+    : KUndo2Command(kundo2_i18n("Set HDR Content Light Level"), parent)
+    , m_image(image)
+    , m_clli(clli)
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (img) {
+        m_oldClli = img->relativeContentLightLevelInformation();
+    }
+}
+
+void KisChangeImageHdrContentLightLevelCommand::redo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+    if (img->relativeContentLightLevelInformation() != m_clli) {
+        img->setRelativeContentLightLevelInformation(m_clli);
+    }
+}
+
+void KisChangeImageHdrContentLightLevelCommand::undo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+    img->setRelativeContentLightLevelInformation(m_oldClli);
+}
+
+int KisChangeImageHdrContentLightLevelCommand::id() const
+{
+    return KisCommandUtils::ChangeImageHdrContentLightLevelId;
+}
+
+bool KisChangeImageHdrContentLightLevelCommand::mergeWith(const KUndo2Command *otherCommand)
+{
+    const KisChangeImageHdrContentLightLevelCommand *other = dynamic_cast<const KisChangeImageHdrContentLightLevelCommand *>(otherCommand);
+    if (!other || other->m_image != m_image) return false;
+
+    m_clli = other->m_clli;
+    return true;
+}
diff --git a/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.h b/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.h
new file mode 100644
index 00000000000..75b6246a9a8
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrContentLightLevelCommand.h
@@ -0,0 +1,32 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KISCHANGEIMAGEHDRMETADATACOMMAND_H
+#define KISCHANGEIMAGEHDRMETADATACOMMAND_H
+
+#include <kundo2command.h>
+#include <kis_types.h>
+#include <kis_hdr_metadata.h>
+#include "kritaimage_export.h"
+
+class KRITAIMAGE_EXPORT KisChangeImageHdrContentLightLevelCommand : public KUndo2Command
+{
+public:
+    KisChangeImageHdrContentLightLevelCommand(KisImageWSP image,
+                                     std::optional<KisRelativeContentLightLevelInformation> clli,
+                                     KUndo2Command *parent = nullptr);
+
+    void redo() override;
+    void undo() override;
+
+    int id() const override;
+    bool mergeWith(const KUndo2Command *other) override;
+private:
+    KisImageWSP m_image;
+    std::optional<KisRelativeContentLightLevelInformation> m_clli;
+    std::optional<KisRelativeContentLightLevelInformation> m_oldClli;
+};
+
+#endif // KISCHANGEIMAGEHDRMETADATACOMMAND_H
diff --git a/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
new file mode 100644
index 00000000000..c0e17ac6ee1
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
@@ -0,0 +1,51 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "KisChangeImageHdrDiffuseWhiteCommand.h"
+#include "kis_command_ids.h"
+#include <kis_image.h>
+
+KisChangeImageHdrDiffuseWhiteCommand::KisChangeImageHdrDiffuseWhiteCommand(KisImageWSP image,
+                                                                                     std::optional<double> diffuseWhite,
+                                                                                     KUndo2Command *parent)
+    : KUndo2Command(kundo2_i18n("Set HDR Diffuse White Light Level"), parent)
+    , m_image(image)
+    , m_diffuseWhite(diffuseWhite)
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (img) {
+        m_diffuseWhite = img->diffuseWhiteLightLevel();
+    }
+}
+
+void KisChangeImageHdrDiffuseWhiteCommand::redo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+    img->setDiffuseWhiteLightLevel(m_diffuseWhite);
+}
+
+void KisChangeImageHdrDiffuseWhiteCommand::undo()
+{
+    KisImageSP img = m_image.toStrongRef();
+    if (!img) return;
+
+    img->setDiffuseWhiteLightLevel(m_oldDiffuseWhite);
+}
+
+int KisChangeImageHdrDiffuseWhiteCommand::id() const
+{
+    return KisCommandUtils::ChangeImageHdrDiffuseWhiteId;
+}
+
+bool KisChangeImageHdrDiffuseWhiteCommand::mergeWith(const KUndo2Command *otherCommand)
+{
+    const KisChangeImageHdrDiffuseWhiteCommand *other = dynamic_cast<const KisChangeImageHdrDiffuseWhiteCommand *>(otherCommand);
+    if (!other || other->m_image != m_image) return false;
+
+    m_diffuseWhite = other->m_diffuseWhite;
+    return true;
+}
diff --git a/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.h b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.h
new file mode 100644
index 00000000000..ac7cb87673b
--- /dev/null
+++ b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.h
@@ -0,0 +1,31 @@
+/*
+ *  SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ *  SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KISCHANGEIMAGEHDRDIFFUSEWHITECOMMAND_H
+#define KISCHANGEIMAGEHDRDIFFUSEWHITECOMMAND_H
+
+#include <kundo2command.h>
+#include <kis_types.h>
+#include "kritaimage_export.h"
+
+class KRITAIMAGE_EXPORT KisChangeImageHdrDiffuseWhiteCommand : public KUndo2Command
+{
+public:
+    KisChangeImageHdrDiffuseWhiteCommand(KisImageWSP image,
+                                              std::optional<double> diffuseWhite,
+                                              KUndo2Command *parent = nullptr);
+
+    void redo() override;
+    void undo() override;
+
+    int id() const override;
+    bool mergeWith(const KUndo2Command *other) override;
+private:
+    KisImageWSP m_image;
+    std::optional<double> m_diffuseWhite;
+    std::optional<double> m_oldDiffuseWhite;
+};
+
+#endif // KISCHANGEIMAGEHDRDIFFUSEWHITECOMMAND_H
diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index a37d10ff03e..63ecbdf6965 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -20,7 +20,6 @@
 
 #include <klocalizedstring.h>
 
-#include "KisContentLightLevelProcessingVistor.h"
 #include "KoColorSpaceRegistry.h"
 #include "KoColor.h"
 #include "KoColorProfile.h"
@@ -2103,26 +2102,6 @@ void KisImage::setRelativeContentLightLevelInformation(const std::optional<KisRe
     }
 }
 
-void KisImage::calculateContentLightLevelInformation(int type)
-{
-
-    KisImageSignalVector emitSignals;
-    KUndo2MagicString actionName;
-    KisProcessingApplicator::ProcessingFlags signalFlags = KisProcessingApplicator::NO_UI_UPDATES | KisProcessingApplicator::RECURSIVE_FRAME_TIMES;
-    KisProcessingApplicator applicator(this, m_d->rootLayer,
-                                       signalFlags,
-                                       emitSignals, actionName);
-
-    KisSharedPtr<KisContentLightLevelProcessingVistor> visitor =
-        new KisContentLightLevelProcessingVistor(KisRelativeContentLightLevelInformation::CalculationType(type));
-    applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::SEQUENTIAL);
-    applicator.end();
-
-    waitForDone();
-    m_d->relativeContentLightLevelInformation = std::make_optional(visitor->contentLightLevelInformation());
-    emit sigContentLightLevelInformationChanged();
-}
-
 std::optional<KisColorVolumeInformation> KisImage::colorVolumeInformation() const
 {
     return m_d->colorVolumeInformation;
diff --git a/libs/image/kis_image.h b/libs/image/kis_image.h
index 59f8ad86234..165d7e4476c 100644
--- a/libs/image/kis_image.h
+++ b/libs/image/kis_image.h
@@ -838,10 +838,6 @@ public:
 public Q_SLOTS:
     void stopIsolatedMode();
 
-    /// Calculates the content light level inside a stroke.
-    /// @param type, see KisContentLightLevelInformation::CalculationType
-    void calculateContentLightLevelInformation(int type = 0);
-
 
 public:
     KisNodeSP isolationRootNode() const;
diff --git a/libs/image/processing/KisContentLightLevelProcessingVistor.h b/libs/image/processing/KisContentLightLevelProcessingVistor.h
index 7633bc8ccc4..d95310efe12 100644
--- a/libs/image/processing/KisContentLightLevelProcessingVistor.h
+++ b/libs/image/processing/KisContentLightLevelProcessingVistor.h
@@ -10,13 +10,14 @@
 #include <kis_do_nothing_processing_visitor.h>
 #include <QScopedPointer>
 #include <kis_hdr_metadata.h>
+#include "kritaimage_export.h"
 
 /**
  * @brief The KisContentLightLevelProcessingVistor class
  * This processing visitor checks the projection of the root level node,
  * and calculates the Content Light Level Information for it.
  */
-class KisContentLightLevelProcessingVistor : public KisDoNothingProcessingVisitor
+class KRITAIMAGE_EXPORT KisContentLightLevelProcessingVistor : public KisDoNothingProcessingVisitor
 {
 
 public:
diff --git a/libs/ui/animation/KisDlgAnimationRenderer.cpp b/libs/ui/animation/KisDlgAnimationRenderer.cpp
index b0fa11eb395..245f862964f 100644
--- a/libs/ui/animation/KisDlgAnimationRenderer.cpp
+++ b/libs/ui/animation/KisDlgAnimationRenderer.cpp
@@ -559,8 +559,8 @@ bool KisDlgAnimationRenderer::supportsAudio(const QString &videoType)
 KisHDRMetadataOptions KisDlgAnimationRenderer::optionsFromImage()
 {
     KisHDRMetadataOptions hdrOptions;
-    if (m_image->contentLightLevelInformation()) {
-        hdrOptions.clli = *m_image->contentLightLevelInformation();
+    if (m_image->relativeContentLightLevelInformation()) {
+        hdrOptions.clli = *m_image->relativeContentLightLevelInformation();
     }
     if (m_image->colorVolumeInformation()) {
         hdrOptions.cvi = *m_image->colorVolumeInformation();
diff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/kis_dlg_image_properties.cc
index 338fcf591ed..e67ff4e9bd0 100644
--- a/libs/ui/dialogs/kis_dlg_image_properties.cc
+++ b/libs/ui/dialogs/kis_dlg_image_properties.cc
@@ -24,6 +24,17 @@
 #include <kis_display_color_converter.h>
 #include <KisWidgetConnectionUtils.h>
 
+#include <kis_processing_applicator.h>
+#include <kis_image_signal_router.h>
+#include <kis_undo_adapter.h>
+#include <kis_types.h>
+#include <kis_group_layer.h>
+
+#include <commands_new/KisChangeImageHdrContentLightLevelCommand.h>
+#include <commands_new/KisChangeImageHdrColorVolumeCommand.h>
+#include <commands_new/KisChangeImageHdrDiffuseWhiteCommand.h>
+#include <KisContentLightLevelProcessingVistor.h>
+
 #include "KisProofingConfigModel.h"
 
 struct KisDlgImageProperties::Private {
@@ -248,12 +259,13 @@ void KisDlgImageProperties::updateHDRLightLevels()
         m_page->gbxDiffuseWhite->setChecked(false);
         m_page->spnDiffuseWhite->setValue(80);
     }
-    if (d->image->contentLightLevelInformation()) {
+    if (d->image->relativeContentLightLevelInformation()) {
         m_page->gbxContentLightLevel->setChecked(true);
         double diffuseWhite = d->image->diffuseWhiteLightLevel()? *d->image->diffuseWhiteLightLevel(): 80.0;
-        KisRelativeContentLightLevelInformation clli = *d->image->contentLightLevelInformation();
+        KisRelativeContentLightLevelInformation clli = *d->image->relativeContentLightLevelInformation();
         m_page->spnMaxCll->setValue(clli.maxContentLightLevel*diffuseWhite);
         m_page->spnMaxFall->setValue(clli.maxFrameAverageLightLevel*diffuseWhite);
+        m_page->cmbLumiCalcType->setCurrentIndex(clli.type);
     } else {
         m_page->gbxContentLightLevel->setChecked(false);
     }
@@ -286,28 +298,38 @@ void KisDlgImageProperties::updateHDRColorVolume()
 
 void KisDlgImageProperties::setHDRLightLevelsOnImage()
 {
+    KUndo2Command *cmd;
     if (m_page->gbxContentLightLevel->isChecked()) {
         double diffuseWhite = d->image->diffuseWhiteLightLevel()? *d->image->diffuseWhiteLightLevel(): 80.0;
         KisRelativeContentLightLevelInformation clli;
         clli.maxContentLightLevel = m_page->spnMaxCll->value() / diffuseWhite;
         clli.maxFrameAverageLightLevel = m_page->spnMaxFall->value() / diffuseWhite;
-        d->image->setRelativeContentLightLevelInformation(std::make_optional(clli));
+        clli.type = KisRelativeContentLightLevelInformation::CalculationType(m_page->cmbLumiCalcType->currentData().toInt());
+        cmd = new KisChangeImageHdrContentLightLevelCommand(d->image, std::make_optional(clli));
     } else {
-        d->image->setRelativeContentLightLevelInformation(std::nullopt);
+        cmd = new KisChangeImageHdrContentLightLevelCommand(d->image, std::nullopt);
+    }
+    if (cmd) {
+        d->image->undoAdapter()->addCommand(cmd);
     }
 }
 
 void KisDlgImageProperties::setHDRDiffuseLevelOnImage()
 {
+    KUndo2Command *cmd;
     if (m_page->gbxDiffuseWhite->isChecked()) {
-        d->image->setDiffuseWhiteLightLevel(std::make_optional(m_page->spnDiffuseWhite->value()));
+        cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, std::make_optional(m_page->spnDiffuseWhite->value()));
     } else {
-        d->image->setDiffuseWhiteLightLevel(std::nullopt);
+        cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, std::nullopt);
+    }
+    if (cmd) {
+        d->image->undoAdapter()->addCommand(cmd);
     }
 }
 
 void KisDlgImageProperties::setHDRColorVolumeOnImage()
 {
+    KUndo2Command *cmd;
     if (m_page->gbxColorVolume->isChecked()) {
         KisColorVolumeInformation cvi;
 
@@ -320,9 +342,12 @@ void KisDlgImageProperties::setHDRColorVolumeOnImage()
         cvi.maxLuminance = m_page->spnMaxLuminance->value();
         cvi.minLuminance = m_page->spnMinLuminance->value();
 
-        d->image->setColorVolumeInformation(std::make_optional(cvi));
+        cmd = new KisChangeImageHdrColorVolumeCommand(d->image, std::make_optional(cvi));
     } else {
-        d->image->setColorVolumeInformation(std::nullopt);
+        cmd = new KisChangeImageHdrColorVolumeCommand(d->image, std::nullopt);
+    }
+    if (cmd) {
+        d->image->undoAdapter()->addCommand(cmd);
     }
 }
 
@@ -366,10 +391,24 @@ void KisDlgImageProperties::changeColorVolumePreset()
     }
 }
 
+
 void KisDlgImageProperties::slotCalculateLightLevels()
 {
-    int type = m_page->cmbLumiCalcType->currentData().toInt();
-    d->image->calculateContentLightLevelInformation(type);
+    KisRelativeContentLightLevelInformation::CalculationType type = KisRelativeContentLightLevelInformation::CalculationType(m_page->cmbLumiCalcType->currentData().toInt());
+
+    KisProcessingApplicator::ProcessingFlags signalFlags = KisProcessingApplicator::NO_UI_UPDATES | KisProcessingApplicator::RECURSIVE_FRAME_TIMES;
+    KisProcessingApplicator applicator(d->image, d->image->rootLayer(),
+                                       signalFlags);
+
+    KisSharedPtr<KisContentLightLevelProcessingVistor> visitor =
+        new KisContentLightLevelProcessingVistor(type);
+    applicator.applyVisitorAllFrames(visitor, KisStrokeJobData::SEQUENTIAL);
+    applicator.end();
+
+    d->image->waitForDone();
+
+    KUndo2Command *cmd = new KisChangeImageHdrContentLightLevelCommand(d->image, std::make_optional(visitor->contentLightLevelInformation()));
+    d->image->undoAdapter()->addCommand(cmd);
 }
 
 void KisDlgImageProperties::slotColorSpaceChanged(const KoColorSpace *cs)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.