Search code examples
c#.net-6.0imagesharp

ImageSharp RecolorBrush not available anymore?


I'm using ImageSharp version 2.1.3 in a .NET 6 project. Now the API which I can use seems to be different from what is shown in the official documentation. For instance the docs are pointing to a namespace SixLabors.ImageSharp.Drawing which is not part of the NuGet package I received.

One thing I cannot find is the RecolorBrush documented here. It allows me to replace a color with another one like this:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Processing;

using (var image = Image.Load('file.png'))
{
    var brush = new RecolorBrush(Color.White, Color.Transparent, 0.2F);
    image.Mutate(ctx => ctx.Fill(brush));
    image.Save('transparent.png');
}

Several things are now not working:

  1. RecolorBrush is not a thing in my Nuget.
  2. ctx.Fill seems to be no longer available.

So am I missing a package, is this a breaking change and if yes what is the new way to do it and where can I find some official info on this?


Solution

  • I could solve this. Big shoutout to @madreflection which answer pointed me to the fact that I had to enable Nuget prereleases.