Repository navigation
fix(hide): Black box is black on CMYK, and extra TIFF channels are covered - #964
Merged
Merged
Conversation
The KnifeLemon#930 review asked to check Black box on CMYK pictures. It came out white: an sRGB black image copied in channel by channel is C, M, Y and K all 0. What was under it was still gone, but the box wasn't black. - AreaHider.Box makes the black image in the picture's own colour space, so a CMYK picture gets C 0, M 0, Y 0, K 255 and a grey one 0. - A CMYK test (TIFF and JPEG) with black-ink text built in code; it fails on main with 0,0,0,0. - Rewraps the comments and headers KnifeLemon#930 added at 120 columns, as the review asked. Comments only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A TIFF can carry channels beside its colours and alpha (extra samples, read as meta channels). Pixelate and Black box paste in an image with colours and alpha only, so those channels kept the part pixel for pixel in the saved file. Blur works on a copy of the picture and covered them. - ClearExtraChannels sets them to 0 inside the part after Pixelate and Black box, through a copy of the part (which keeps every channel), so the picture's pixels are never written directly. - A test with an RGBA TIFF and two extra channels of noise, for both styles; it fails on main with the original values still there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KnifeLemon
approved these changes
Nov 1, 2026
KnifeLemon
left a comment
Owner
There was a problem hiding this comment.
Thanks for following up so quickly, @lightscape-jm, and for measuring instead of guessing.
- CMYK: making the black image in the picture's own colour space is the right one-line fix. Keeping the composite is fine; no need to switch to a crop.
- Extra channels: good catch. A TIFF's extra samples keeping the hidden part pixel for pixel is exactly the kind of leak this tool must not have. Copying the part out, clearing those channels and copying it back keeps the rule that the picture's pixels aren't written directly.
- The comments are rewrapped too.
CI is green. Merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
Follows up the two notes from the #930 review.
1. CMYK pictures: you were right to ask. On a CMYK picture a Black box came out white, not black.
Boxcopied an sRGB black image into the picture channel by channel, which gave C, M, Y and K all 0: white paper. What was under the box was still gone (every pixel inside it was the same white, black-ink text included), so nothing could be read back, but it wasn't the black box the user drew.The fix is one line: the black image is made in the picture's own colour space (
black.ColorSpace = image.ColorSpace) before it is copied in. sRGB black becomes C 0, M 0, Y 0, K 255 in a CMYK picture, and 0 in a grey one. I kept the composite rather than filling a crop of the picture, as the new image already copies every pixel and its alpha, and the change stays small. Happy to switch if you prefer the crop.Pixelate and Blur were already right on CMYK (measured: the covered colour matches the original), and grey pictures were already black.
2. Extra channels (found while checking 1): a TIFF can carry channels beside its colours and alpha (extra samples, which ImageMagick reads as meta channels). Pixelate and Black box paste in an image that has only colours and alpha, so those channels kept the part pixel for pixel, and the saved TIFF still had them. Blur works on a copy of the picture and covered them already. A new
ClearExtraChannelssets them to 0 inside the part after Pixelate and Black box. It copies the part out (which keeps every channel), clears them there and copies it back, so the picture's pixels are never written directly (the note on Pixelate says why). Pictures without extra channels are not touched. This one has been in Pixelate since the tool was added.3. Comment wrapping: the comments and file headers that #930 added or changed in
HideTool.cs,AreaHider.cs,Preset.csandHideAreaSet.csare rewrapped at 120, as are the others from that PR (HideCanvas.cs,HideWindowViewModel.cs,HideWindow.axaml,HideAreasTests.cs). Comments only; no code lines changed.Type of change
How was it tested?
dotnet format --verify-no-changesdotnet test: Core and the App Pixelate / blur tests pass, and the new test passes. On my Mac the same 6 Engines tests fail on unmodifiedmain(FFmpeg without some encoders, LibreOffice).And on a TIFF with two extra channels of noise (sampled inside the part, original values left in each extra channel):
New tests (
tests/Filee.Engines.Tests/HideAreasTests.cs):Extra_channels_of_a_tiff_keep_nothing_of_the_part(Pixelate and Black box)main(the original 184 is still there).A_black_box_on_a_cmyk_picture_is_full_black_ink_and_its_text_is_gone(TIFF and JPEG)mainwith0,0,0,0.Screenshots (UI changes)
None: the window draws boxes black already; only the saved file changes.
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (none)THIRD-PARTY-NOTICES.md(none)🤖 Generated with Claude Code