VOOZH about

URL: https://www.nuget.org/packages/Imageflow.AllPlatforms/

⇱ NuGet Gallery | Imageflow.AllPlatforms 0.15.1




👁 Image
Imageflow.AllPlatforms 0.15.1

Prefix Reserved
dotnet add package Imageflow.AllPlatforms --version 0.15.1
 
 
NuGet\Install-Package Imageflow.AllPlatforms -Version 0.15.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Imageflow.AllPlatforms" Version="0.15.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Imageflow.AllPlatforms" Version="0.15.1" />
 
Directory.Packages.props
<PackageReference Include="Imageflow.AllPlatforms" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Imageflow.AllPlatforms --version 0.15.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Imageflow.AllPlatforms, 0.15.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Imageflow.AllPlatforms@0.15.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Imageflow.AllPlatforms&version=0.15.1
 
Install as a Cake Addin
#tool nuget:?package=Imageflow.AllPlatforms&version=0.15.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 Build status

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 targets .NET 10, .NET 8, and .NET Standard 2.0/2.1, making it compatible with .NET 8+, .NET Framework 4.6.2+, and .NET Core 2.0+. Native runtimes are provided for x64, ARM64, and x86 on Windows, Linux, and macOS.

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 8+ (or if using PackageReference on .NET 4.x)

dotnet add package Imageflow.AllPlatforms
.NET 4.X: A note on PackageReference and Any CPU

If your project uses PackageReference and targets the Any CPU platform, you must add <RuntimeIdentifiers> to your .csproj file. This is because this library contains native code, and MSBuild needs to know which native assets to use for the ambiguous Any CPU target.

Without this, you may see an error like Your project file doesn't list 'win' as a "RuntimeIdentifier".

Add the following to your project's primary <PropertyGroup>:

<RuntimeIdentifiers>win;win-x64;win-x86</RuntimeIdentifiers>

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 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Imageflow.AllPlatforms:

Package Downloads
Ewl

The Enterprise Web Library (EWL), together with its tailored infrastructure platform, is a highly opinionated foundation for web-based enterprise software.

Imageflow.Server

Imageflow.Server - Middleware for fetching, processing, and caching images on-demand. Commercial licenses available.

BaDaBoom

RAD Framework for the IAM stack

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Imageflow.AllPlatforms:

Repository Stars
imazen/resizer
The official repository for ImageResizer
imazen/imageflow-server
A super-fast image server to speed up your site - deploy as a microservice, serverless, or embeddable.