Search code examples
imagesharp

Transparent background using ImageSharps BinaryThreshold


Looking at the source code for BinaryThreshold in the ImageSharp library, there are properties for the upper and lower threshold colours BinaryThresholdProcessor.cs.

I'd like to make an image that instead of having a white background, has a transparent one for the lower threshold. If I had access to these properties I could do that. Is there any way?

Thanks.


Solution

  • You're absolutely correct. The underpinnings were there for allowing such behaviour but the functionality was not enabled.

    On the back of your question I've updated all the thresholding/dithering code in the library to allow what you need.

    https://github.com/SixLabors/ImageSharp/pull/456

    Once merged, this will be in the nightly builds available from Myget. We have a beta3 scheduled very soon for Nuget also.