Announcing ImageSharp 2.0.0

ImageSharp 2 - Harder, Better, Faster, Stronger!

We are very excited to announce the release of ImageSharp 2.0.0 final. You can download it today.

We've been putting this release together for a while but it's been well worth the wait. This is a MASSIVE release with some fantastic improvements.

What's new since V1 #

So many things. Too many to list!

  • WebP support - People have been after this for a while! We provide comprehensive support for decoding and encoding WebP images.
  • Tiff support - Comprehensive support for decoding and encoding Tiff images.
  • Pbm support - Comprehensive support for decoding and encoding Pbm images.
  • XMP metadata support.
  • A complete overhaul of how we manage memory pooling with a new faster and much more efficient unmanaged memory allocator.
  • Massive performance improvements for our Jpeg and Png formats.
  • Massive performance improvements for our quantization algorithms.
  • Various bug fixes and enhancements

Breaking Changes #

  • Png and Jpeg now decode to pixels formats representative of the encoded format when using the non-generic API. This was done to improve memory usage and remove some surprises for users.
  • We've changed the way that underlying spans are accessed in high performance scenarios. This was done to improve memory safety.
  • We've dropped the old NetStandard 1.3 target. This targeted frameworks not supported by Microsoft and was adding overhead to development.

Read the release notes for detailed release information.

API documentation is available in our Docs site.

Performance #

We've come a VERY long way since people started measuring our performance back in 2017. Back then we were about 3.5x slower than System.Drawing.

Now... Well it's a very different picture.

Here's the same benchmarks using ImageSharp V2. They're running on a four year old Surface Book 2 called Mjölnir with 16.0 GB of RAM.

BenchmarkDotNet=v0.13.1.1693-nightly, OS=Windows 11 (10.0.22000.434/21H2)
Intel Core i7-8650U CPU 1.90GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.101
  [Host]   : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
  ShortRun : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT

Job=ShortRun  Arguments=/p:DebugType=portable  IterationCount=5
LaunchCount=1  WarmupCount=5

|                                Method |      Mean |     Error |   StdDev | Ratio | Allocated native memory | Native memory leak |     Gen 0 |     Gen 1 |     Gen 2 | Allocated | Alloc Ratio |
|-------------------------------------- |----------:|----------:|---------:|------:|------------------------:|-------------------:|----------:|----------:|----------:|----------:|------------:|
|   'System.Drawing Load, Resize, Save' | 494.34 ms | 20.543 ms | 3.179 ms |  1.00 |               11,376 KB |             738 KB |         - |         - |         - |  12.65 KB |        1.00 |
|       'ImageSharp Load, Resize, Save' | 164.93 ms |  4.293 ms | 1.115 ms |  0.33 |                   10 KB |                  - |         - |         - |         - | 1493.8 KB |      118.10 |
|      'ImageMagick Load, Resize, Save' | 521.40 ms |  3.979 ms | 0.616 ms |  1.05 |               61,408 KB |                  - |         - |         - |         - |  54.55 KB |        4.31 |
|        'ImageFree Load, Resize, Save' | 338.20 ms |  2.969 ms | 0.771 ms |  0.68 |               49,137 KB |              58 KB | 6000.0000 | 6000.0000 | 6000.0000 |  94.82 KB |        7.50 |
|      'MagicScaler Load, Resize, Save' |  85.87 ms |  0.621 ms | 0.096 ms |  0.17 |                3,088 KB |             178 KB |         - |         - |         - | 149.58 KB |       11.83 |
| 'SkiaSharp Canvas Load, Resize, Save' | 303.41 ms |  3.607 ms | 0.937 ms |  0.61 |               69,710 KB |           1,662 KB |         - |         - |         - | 101.73 KB |        8.04 |
| 'SkiaSharp Bitmap Load, Resize, Save' | 303.46 ms |  3.602 ms | 0.935 ms |  0.61 |               70,424 KB |             949 KB |         - |         - |         - |  87.66 KB |        6.93 |
|          'NetVips Load, Resize, Save' | 167.79 ms | 18.510 ms | 4.807 ms |  0.34 |               28,786 KB |               0 KB |         - |         - |         - |  49.62 KB |        3.92 |

// * Legends *
  Mean                    : Arithmetic mean of all measurements
  Error                   : Half of 99.9% confidence interval
  StdDev                  : Standard deviation of all measurements
  Ratio                   : Mean of the ratio distribution ([Current]/[Baseline])
  Allocated native memory : Allocated native memory per single operation
  Native memory leak      : Native memory leak size in byte.
  Gen 0                   : GC Generation 0 collects per 1000 operations
  Gen 1                   : GC Generation 1 collects per 1000 operations
  Gen 2                   : GC Generation 2 collects per 1000 operations
  Allocated               : Allocated memory per single operation (managed only, inclusive, 1KB = 1024B)
  Alloc Ratio             : Allocated memory ratio distribution ([Current]/[Baseline])
  1 ms                    : 1 Millisecond (0.001 sec)

We're now 3x faster than System.Drawing 🚀. We're actually now the fastest cross platform library in the benchmark!

This is the result of years of improvements to the library, measuring and optimizing bottlenecks to our processes. As we look forward we shall continue to optimize our code taking advantage of new .NET APIs and language improvements.

The Future #

We'll be publishing new releases over the next few days of all our libraries that depend on ImageSharp. That means a new major version SixLabors.ImageSharp.Web and new betas of SixLabors.ImageSharp.Drawing and SixLabors.Fonts. We'll be focussing very heavily on the latter two libraries to bring them up to Release Candidate status.

Following that we'll start looking towards V3 where the focus will be on adopting the latest .NET runtimes and bringing high performance on as many platforms as possible.

ImageSharp V2 is released under dual licenses:

Closing #

Thanks again for all the feedback and usage. It's been a pleasure to build ImageSharp so far and to see so many people try it out; we really appreciate it. Please continue exploring the product and learning what it’s capable of.