Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Add ability to select color profile to Batch Exporter

Kitlith ~~c05bb8e393e0
diff --git a/plugins/python/batch_exporter/Config.py b/plugins/python/batch_exporter/Config.py
index 298586d4ab..a042568426 100644
--- a/plugins/python/batch_exporter/Config.py
+++ b/plugins/python/batch_exporter/Config.py
@@ -12,6 +12,6 @@ CONFIG = {
"error": {"msg": "ERROR: {}", "timeout": 8000},
"done": {"msg": "DONE: {}", "timeout": 5000},
"delimiters": OrderedDict((("assign", "="), ("separator", ","))), # yapf: disable
- "meta": {"c": [""], "e": ["png"], "m": [0], "p": [""], "t": [""], "s": [100], "i": [""], "b": [""]},
+ "meta": {"c": [""], "e": ["png"], "m": [0], "p": [""], "t": [""], "s": [100], "i": [""], "b": [""], "icc": ["sRGB-elle-V2-srgbtrc.icc"]},
}
CONFIG["sym"] = re.compile(CONFIG["sym"])
diff --git a/plugins/python/batch_exporter/Infrastructure.py b/plugins/python/batch_exporter/Infrastructure.py
index d1965f0ad6..47f8c7c0f3 100644
--- a/plugins/python/batch_exporter/Infrastructure.py
+++ b/plugins/python/batch_exporter/Infrastructure.py
@@ -26,20 +26,20 @@ def nodeToImage(wnode):
"""
Returns an QImage 8-bit sRGB
"""
- SRGB_PROFILE = "sRGB-elle-V2-srgbtrc.icc"
+ icc_profile = (wnode.meta.get("icc") or wnode.cfg["meta"]["icc"])[0]
[x, y, w, h] = wnode.bounds
- is_srgb = (
+ conversion_not_needed = (
wnode.node.colorModel() == "RGBA"
and wnode.node.colorDepth() == "U8"
- and wnode.node.colorProfile().lower() == SRGB_PROFILE.lower()
+ and wnode.node.colorProfile().lower() == icc_profile.lower()
)
- if is_srgb:
+ if conversion_not_needed:
pixel_data = wnode.node.projectionPixelData(x, y, w, h).data()
else:
temp_node = wnode.node.duplicate()
- temp_node.setColorSpace("RGBA", "U8", SRGB_PROFILE)
+ temp_node.setColorSpace("RGBA", "U8", icc_profile)
pixel_data = temp_node.projectionPixelData(x, y, w, h).data()
return QImage(pixel_data, w, h, QImage.Format.Format_ARGB32)