We are very excited to announce the release of ImageSharp.Web 3.0.0 final. You can download it today.
This release is the culmination of over 8 months of work and marks a major shift in the development of ImageSharp.Web.
With V3 we've changed the target framework to support the latest .NET 6 LTS.
By removing support for legacy frameworks we've been able to delete a lot of old code that was preventing us from providing much needed improvements throughout the library. As a result we've been able to simplify many of our internal and public APIs and deliver incredible performance improvements in several areas.
Going forward each major version will only support the current .NET LTS.
Don't worry! The V2 package is not going anywhere so if you cannot update your target framework we've still got you covered.
V3 will also be the first version to use the new Six Labors Split License.
What's new since V2 #
- Changed the base ImageSharp version to v3.0.1
- Added Tag Helper support to facilitate easier command generation.
Breaking Changes #
- We've introduce support for Nullable Reference Types across all our APIs which will change the method signatures in several places.
Read the release notes for detailed release information.
API documentation is available in our Docs site.
One of the things we've been wanting to solve for our customers for a while is an easier way to generate the commands required to process image requests. There are lots of commands to remember and when we added HMAC support in V2 we added a level of complexity we weren't happy with.
To solve this issue we turned to ASP.NET tag helpers.
ASP.NET tag helpers are useful because they provide a more natural syntax for creating HTML elements in server-side code. They allow developers to create HTML elements in a way that is similar to how they would write HTML markup in a Razor view.
Some of the benefits of using tag helpers include:
- Improved readability: Tag helpers make it easier to understand the purpose of the code by providing a clear and concise syntax that is closer to HTML.
- Reduced complexity: Tag helpers simplify the creation of complex HTML elements by reducing the amount of boilerplate code needed.
- Type safety: Tag helpers are strongly typed, which means that the compiler can catch errors at compile time rather than at runtime.
- Testability: Tag helpers make it easier to unit test server-side code by providing a cleaner separation of concerns between the server-side code and the HTML markup.
- Code reuse: Tag helpers can be used to encapsulate commonly used HTML elements, making it easier to reuse code across multiple views and pages.
Overall, ASP.NET tag helpers provide a more efficient and maintainable way to create HTML elements in server-side code.
ImageSharp.Web V3 comes equipped with a custom tag helper called ImageTagHelper that allows the generation of all the commands supported by the middleware in an easily accessible manner. This includes automatic generation of HMAC command tokens.
To use ImageTagHelper, all you have to do is add the following imports command to
_ViewImports.cshtml in your project.
@addTagHelper *, SixLabors.ImageSharp.Web
All ImageSharp.Web commands are strongly typed and prefixed with
imagesharp to namespace them against potentially conflicting commands. Visual Studio intellisense with automatically provide guidance
once you start typing.
The syntax is concise and easy to follow.
For example, in the following markup snippet we are asking the tag helper to generate a command that will resize the image to 300x200 px using padding if required and also set the background color of any additional padded sections to lime green.
<img src="sixlabors.imagesharp.web.png" imagesharp-width="300" imagesharp-height="200" imagesharp-rmode="ResizeMode.Pad" imagesharp-rcolor="Color.LimeGreen" />
The TagHelper will translate this markup to generate the following request url containing all the commands translated into a format the middleware can understand. It also transparently adds the matching HMAC token when the functionality is enabled and configured.
As you can see this massively simplifies command generation. An added bonus is that this functionality is also available to customers generating custom commands; we've made the ImageTagHelper type unsealed so that you can inherit the type and bring your own.
You can see the collection of supported properties an option in the API documentation.
The Future #
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.
Thanks again for all the feedback and usage. It's been a pleasure to build ImageSharp.Web 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.