Imageflow.Net
0.13.2
Prefix Reserved
dotnet add package Imageflow.Net --version 0.13.2
NuGet\Install-Package Imageflow.Net -Version 0.13.2
<PackageReference Include="Imageflow.Net" Version="0.13.2" />
paket add Imageflow.Net --version 0.13.2
#r "nuget: Imageflow.Net, 0.13.2"
// Install Imageflow.Net as a Cake Addin #addin nuget:?package=Imageflow.Net&version=0.13.2 // Install Imageflow.Net as a Cake Tool #tool nuget:?package=Imageflow.Net&version=0.13.2
Imageflow.NET is a .NET API for Imageflow, the fast image optimization and processing library for web servers. Imageflow focuses on security, quality, and performance - in that order. Imageflow.NET is a .NET 8.0 & .NET Standard 2.0 library, and as such is compatible with .NET 4.6.2+, .NET Core 2.0+, and .NET 5/6/7/8/9.
Note: We recently switched from Newtonsoft to System.Text.Json to support AOT and trimming; see CHANGES.md for details and some breaking changes. There are also new classes for attaching source image data to jobs; use MemorySource.* over ByteSource and BufferedStreamSource.* instead of StreamSource.
On .NET Core 3.x and .NET 5/6/7/8 (or if using PackageReference on .NET 4.x)
dotnet add package Imageflow.AllPlatforms
If you're still using packages.config on .NET 4.x (such as for ASP.NET projects), you have to install Imageflow directly
PM> Install-Package Imageflow.Net
PM> Install-Package Imageflow.NativeRuntime.win-x86 -pre
PM> Install-Package Imageflow.NativeRuntime.win-x86_64 -pre
PM> Install-Package Imageflow.NativeRuntime.osx-x86_64 -pre
PM> Install-Package Imageflow.NativeRuntime.ubuntu-x86_64 -pre
Note: On .NET 4.x you must install the appropriate NativeRuntime(s) in the project you are deploying - they have to copy imageflow.dll to the output folder. They are not copied transitively.
Also note: Older versions of Windows may not have the C Runtime installed (Install 32-bit or 64-bit).
License
- Imageflow is dual licensed under a commercial license and the AGPLv3.
- Imageflow.NET is tri-licensed under a commercial license, the AGPLv3, and the Apache 2 license.
- Imageflow.NET Server is dual licensed under a commercial license and the AGPLv3.
- We offer commercial licenses at https://imageresizing.net/pricing
- Imageflow.NET's Apache 2 license allows for integration with non-copyleft products, as long as jobs are not actually executed (since the AGPLv3/commercial license is needed when libimageflow is linked at runtime). This can allow end-users to benefit from optional imageflow integration in products.
Examples
Getting image dimensions and format
using Imageflow.Fluent;
public async void TestGetImageInfo()
{
var imageBytes = Convert.FromBase64String(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=");
var info = await ImageJob.GetImageInfo(new MemorySource(imageBytes));
Assert.Equal(info.ImageWidth, 1);
Assert.Equal(info.ImageHeight, 1);
Assert.Equal(info.PreferredExtension, "png");
Assert.Equal(info.PreferredMimeType, "image/png");
}
Edit images with the fluent API
using Imageflow.Fluent;
public async Task TestAllJob()
{
var imageBytes = Convert.FromBase64String(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=");
using (var b = new ImageJob())
{
var r = await b.Decode(imageBytes)
.FlipVertical()
.FlipHorizontal()
.Rotate90()
.Rotate180()
.Rotate270()
.Transpose()
.CropWhitespace(80, 0.5f)
.Distort(30, 20)
.Crop(0,0,10,10)
.Region(-5,-5,10,10, AnyColor.Black)
.RegionPercent(-10f, -10f, 110f, 110f, AnyColor.Transparent)
.BrightnessSrgb(-1f)
.ContrastSrgb(1f)
.SaturationSrgb(1f)
.WhiteBalanceSrgb(80)
.ColorFilterSrgb(ColorFilterSrgb.Invert)
.ColorFilterSrgb(ColorFilterSrgb.Sepia)
.ColorFilterSrgb(ColorFilterSrgb.Grayscale_Bt709)
.ColorFilterSrgb(ColorFilterSrgb.Grayscale_Flat)
.ColorFilterSrgb(ColorFilterSrgb.Grayscale_Ntsc)
.ColorFilterSrgb(ColorFilterSrgb.Grayscale_Ry)
.ExpandCanvas(5,5,5,5,AnyColor.FromHexSrgb("FFEECCFF"))
.FillRectangle(2,2,8,8, AnyColor.Black)
.ResizerCommands("width=10&height=10&mode=crop")
.ConstrainWithin(5, 5)
.Watermark(new BytesSource(imageBytes),
new WatermarkOptions()
.SetMarginsLayout(
new WatermarkMargins(WatermarkAlign.Image, 1,1,1,1),
WatermarkConstraintMode.Within,
new ConstraintGravity(90,90))
.SetOpacity(0.5f)
.SetHints(new ResampleHints().SetSharpen(15f, SharpenWhen.Always))
.SetMinCanvasSize(1,1))
.EncodeToBytes(new MozJpegEncoder(80,true))
.Finish().InProcessAsync();
Assert.Equal(5, r.First.Width);
Assert.True(r.First.TryGetBytes().HasValue);
}
}
Generate multiple versions of one image
using Imageflow.Fluent;
public async Task TestMultipleOutputs()
{
var imageBytes = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=");
using (var b = new ImageJob())
{
var r = await b.Decode(imageBytes).
Constrain(new Constraint(ConstraintMode.Fit, 160, 120))
.Branch(f => f.ConstrainWithin(80, 60).EncodeToBytes(new WebPLosslessEncoder()))
.Branch(f => f.ConstrainWithin(40, 30).EncodeToBytes(new WebPLossyEncoder(50)))
.EncodeToBytes(new LodePngEncoder())
.Finish().InProcessAsync();
Assert.Equal(60, r.TryGet(1).Width);
Assert.Equal(30, r.TryGet(2).Width);
Assert.Equal(120, r.TryGet(3).Width);
Assert.True(r.First.TryGetBytes().HasValue);
}
}
Edit images using a command string
using Imageflow.Fluent;
public async Task TestBuildCommandString()
{
var imageBytes = Convert.FromBase64String(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=");
// We wrap the job in a using() statement to free memory faster
using (var b = new ImageJob())
{
var r = await b.BuildCommandString(
new MemorySource(imageBytes), // or new StreamSource(Stream stream, bool disposeStream)
new BytesDestination(), // or new StreamDestination
"width=3&height=2&mode=stretch&scale=both&format=webp&webp.quality=80")
.Finish().InProcessAsync();
Assert.Equal(3, r.First.Width);
Assert.Equal("webp", r.First.PreferredExtension);
Assert.True(r.First.TryGetBytes().HasValue);
}
}
More examples are in the tests
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.IO.RecyclableMemoryStream (>= 3.0.0 && < 4.0.0)
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Text.Json (>= 6.0.9)
-
.NETStandard 2.1
- Microsoft.IO.RecyclableMemoryStream (>= 3.0.0 && < 4.0.0)
- System.Text.Json (>= 6.0.9)
-
net8.0
- Microsoft.IO.RecyclableMemoryStream (>= 3.0.0 && < 4.0.0)
- System.Text.Json (>= 6.0.9)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Imageflow.Net:
Package | Downloads |
---|---|
Imageflow.AllPlatforms
Imageflow processes and optimizes images at incredible speeds. Works well with with .NET 8,7,6.. anything with .NET Standard 2.0. NOTE: For .NET 4.x projects, use the Imageflow.Net and Imageflow.NativeRuntime.[your platform] packages separately. |
|
ImageResizer.Plugins.Imageflow
Fast image processing and compression backend for the ImageResizer HttpModule. |
|
Deviser.Core.Library
Provides core functionlities of Deviser Platform. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Imageflow.Net:
Repository | Stars |
---|---|
imazen/resizer
The official repository for ImageResizer
|
Version | Downloads | Last updated |
---|---|---|
0.13.2 | 20,301 | 5/15/2024 |
0.13.1 | 9,934 | 3/9/2024 |
0.13.0 | 331 | 3/8/2024 |
0.12.0 | 33,157 | 2/6/2024 |
0.11.2 | 3,765 | 1/29/2024 |
0.11.1 | 134 | 1/29/2024 |
0.11.0 | 673 | 1/29/2024 |
0.10.2 | 83,828 | 9/26/2023 |
0.10.0 | 45,238 | 4/4/2023 |
0.9.1 | 105,579 | 1/6/2023 |
0.9.0 | 26,688 | 9/30/2022 |
0.8.5 | 9,067 | 8/26/2022 |
0.8.4 | 4,267 | 8/7/2022 |
0.8.3 | 25,339 | 8/4/2022 |
0.8.2 | 31,619 | 6/9/2022 |
0.8.1 | 9,616 | 5/21/2022 |
0.8.0 | 776 | 5/20/2022 |
0.7.31 | 1,301 | 5/19/2022 |
0.7.30 | 451 | 5/19/2022 |
0.7.29 | 449 | 5/19/2022 |
0.7.28 | 438 | 5/19/2022 |
0.7.27 | 447 | 5/19/2022 |
0.7.24 | 213,310 | 3/29/2021 |
0.7.23 | 1,947 | 3/18/2021 |
0.7.22 | 6,362 | 3/18/2021 |
0.7.21 | 20,611 | 1/14/2021 |
0.7.20 | 3,009 | 12/14/2020 |
0.7.19 | 2,117 | 11/22/2020 |
0.7.18 | 521 | 11/22/2020 |
0.7.17 | 403 | 11/22/2020 |
0.7.16 | 430 | 11/22/2020 |
0.7.15 | 439 | 11/22/2020 |
0.7.14 | 421 | 11/22/2020 |
0.7.13 | 452 | 11/22/2020 |
0.7.12 | 492 | 11/22/2020 |
0.7.11 | 572 | 11/22/2020 |
0.7.10 | 6,428 | 11/12/2020 |
0.7.9 | 729 | 11/11/2020 |
0.7.8 | 3,746 | 10/29/2020 |
0.7.7 | 2,019 | 10/12/2020 |
0.7.6 | 6,122 | 9/21/2020 |
0.7.5 | 529 | 9/21/2020 |
0.7.4 | 548 | 9/21/2020 |
0.7.3 | 510 | 9/21/2020 |
0.7.2 | 1,186 | 9/3/2020 |
0.7.1 | 101,923 | 6/17/2020 |
0.7.0 | 554 | 6/17/2020 |
0.6.9 | 713 | 6/16/2020 |
0.6.8 | 1,143 | 6/15/2020 |
0.6.7 | 790 | 6/12/2020 |
0.6.6 | 695 | 6/12/2020 |
0.6.5 | 660 | 6/12/2020 |
0.6.4 | 771 | 6/11/2020 |
0.6.3 | 732 | 6/10/2020 |
0.6.2 | 480 | 6/9/2020 |
0.6.1 | 496 | 6/9/2020 |
0.6.0 | 543 | 6/9/2020 |
0.5.0 | 2,532 | 5/6/2020 |
0.4.4 | 556 | 4/20/2020 |
0.4.3 | 536 | 4/18/2020 |
0.4.2 | 511 | 4/18/2020 |
0.4.1 | 513 | 4/18/2020 |
0.3.4 | 508 | 4/17/2020 |
0.3.3 | 524 | 4/16/2020 |
0.2.6 | 16,938 | 9/15/2017 |
0.2.5 | 894 | 9/15/2017 |
0.2.4 | 920 | 9/13/2017 |
0.2.3 | 909 | 9/13/2017 |
0.2.2 | 916 | 9/13/2017 |
0.2.1 | 1,011 | 9/12/2017 |