Beta 7.

Good news! After spending all the summer waiting impatiently...

...a new Tool album has been finally relased

ImageSharp beta 7 is available on NuGet #

Wait! You told, there will be no more beta versions ... #

We haven't yet reached all our RC1 goals but there were so many improvements in the last few months, we just can't keep them behind the walls of MyGet any longer!

So let's talk about the changes...

API Improvements #

There were several issues about the way the main Image<TPixel>
class was exposed to our users. The pixel type TPixel is a noise for people who just want to do simple things like resize & resave an image. A major design goal of our libraries is to make things as simple as possible. Therefore we decided to no longer force users to operate with types like Image<Rgba32> when Rgba32 is an implementation detail for them.

Previously Image was a static helper class with methods to load images from different data sources.

Starting from beta 7, Image is an abstract, pixel-agnostic base class for the pixel-specific Image<TPixel> generic type.

Non-generic Image.Load overloads no longer return Image<Rgba32>. The pixel-agnostic Image is being returned instead:

using (Image image = Image.Load("foo.jpg"))
{
    image.Mutate(x => x.Resize(100, 100);
    image.SaveAsJpeg(someStream);
}

This change is also opening up optimization opportunities for future versions: if no specific pixel type is forced on the call site, ImageSharp can decode/re-encode images into their "native" pixel formats faster.

Adapting existing code #

Yes, all overloads of the Image.Load(...) method went through a breaking change, and all users should recompile their projects after the package update. On the other hand the impacts should be minimal:

1. Simple processing code using var should be unaffected: #

using (var image = Image.Load("foo.jpg"))
{
    image.Mutate(x => x
         .Resize(image.Width / 2, image.Height / 2);
    image.Save("bar.jpg");
}

2. Code using specific pixel types with Image.Load<T>(...) should be unaffected: #

using (Image<Rgb24> image = Image.Load<Rgb24>("foo.jpg"))
{
    image.Mutate(x => x
         .Resize(image.Width / 2, image.Height / 2);
    image.Save("bar.jpg");
}

3. If the code used to specify Image<Rgba32> with Image.Load(...) #

It could be easily adapted by replacing Image<Rgba32> with Image:

using (Image image = Image.Load("foo.jpg"))
{
    image.Mutate(x => x
         .Resize(image.Width / 2, image.Height / 2);
    image.Save("bar.jpg");
}

4. If the code is strongly depending on the occurences of Image<Rgba32> #

Image.Load(...) could be replaced with Image.Load<Rgba32>(...):

void ProcessMyImage(Image<Rgba32> image)
{
    // do stuff ...
}

using (Image<Rgba32> image = Image.Load<Rgba32>("foo.jpg"))
{
    ProcessMyImage(image);
    image.Save("bar.jpg");
}

Pixel-independent Color and Drawing #

In the spirit of the new, pixel-agnostic Image API-s, we have introduced a new Color type, convertible to any pixel representation:

Bgr565 pixel = Color.Blue.ToPixel<Bgr565>();

Color is enabling drawing API-s on non-generic Image instances:

using (Image image = Image.Load("test.jpg"))
{
    Color color = Color.FromHex("#f2e7cf");
    image.Mutate(x => x.Fill(color, new Rectangle(10, 10, 200, 100)));
}

Consequence on ImageSharp terminology #

During the initial design of the library, we took the assumption that Color and Pixel are synonyms. This is no longer the case: Color is a general term, while Pixel is a specific (and in many cases, limited) representation drawable on an Image<TPixel>.

Obsolete types #

Color has rendered the helper classes ColorBuilder<TPixel> and NamedColors<TPixel> obsolete, and we removed them.

Changelog #

There were 90 separate PRs included in this release, a massive list containing bugfix, performance improvements, and some great additions to the library.

We've vastly increased our Bmp support, added text metadata handling and interlaced encoding support to Png, added Bokeh Blur algorithms, reduced resizing memory consumption, improved Jpeg encoding performance, fixed bugs and much, much more!

Full release notes can be found here..

Special thanks #

As ever, we wouldn't be able to create great releases like this without the help from our ever growing community. We're grateful for everything you do!