Repository navigation
desaturate: succeed on grayscale layers, explain indexed ones (#162) - #192
Conversation
gimp-drawable-desaturate only takes RGB layers, so desaturate failed on a GRAY or INDEXED image with a bare "execution-error", after its undo group had marked the image changed. Check the layer before the undo group: a grayscale layer is already gray, so return success and leave it alone; an indexed one is an error that says to convert the image to RGB first.
|
No actionable comments were generated in the recent review. WalkthroughThe desaturate tool now succeeds without changing grayscale drawables and rejects indexed drawables before opening an undo group. Live tests cover these cases and RGB desaturation. The tool documentation and changelog describe the behavior. ChangesDesaturate mode handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested labels: Suggested reviewers: Merge Risk:
|
Fixes #162.
Problem
desaturateon a GRAY or INDEXED image failed withgimp-drawable-desaturate failed (execution-error), and the image was marked as changed. GIMP'sgimp-drawable-desaturateonly takes RGB layers; the tool called it inside its undo group, so the failure came after the group had dirtied the image, and the message didn't say why.Change
_desaturatechecks the layer before opening the undo group (after themodecheck, so a typo is still an error):layer 'X' is indexed; desaturate needs an RGB image, convert it first (convert_color_mode RGB), asadjust_curvesalready does for indexed layers.The tool's description says both. CHANGELOG entry under
[Unreleased]/ Fixed. No result or parameter changes, so a patch-level fix.Tests
tests/test_desaturate_modes_live.py(new): an RGB layer is still desaturated; a GRAY layer succeeds with pixels and dirty flag unchanged; a badmodeon a GRAY layer is still an error; an INDEXED layer gives the convert-to-RGB error and changes nothing. Fails withmain's plugin (the GRAY case, with the issue'sexecution-error), passes with this one, on GIMP 3.2 (snap).tests/test_pdb_status.py: its fake layer gainsis_gray()/is_indexed()(an RGB layer), moved up from the curves-only fake, so the offlinedesaturatechecks reach the PDB call.test_locked_pixels_live.pyandtest_unknown_options_live.py(which also calldesaturate) still pass live;uvx ruff@0.15.11 checkand all offline tests pass. CodeRabbit CLI review: no findings.Summary by CodeRabbit