Webefinity.ImageLib (0.0.1-beta07)
Installation
dotnet nuget add source --name adrian --username your_username --password your_token dotnet add package --source adrian --version 0.0.1-beta07 Webefinity.ImageLibAbout this package
Managed .NET wrapper for native image codec operations (PNG/JPEG encode and decode) via P/Invoke, with an extensible filter pipeline supporting resize, crop, blur, colour adjustments, blending, and more.
Webefinity.ImageLib
A managed .NET wrapper for native image codec operations (PNG and JPEG encode/decode) via P/Invoke, together with an extensible image filter pipeline.
Installation
dotnet add package Webefinity.ImageLib
Codec API
using ImageLib;
// Decode a PNG file to raw RGBA pixels
byte[] pngBytes = File.ReadAllBytes("input.png");
DecodedImage image = ImageCodec.DecodePngToRgba(pngBytes);
// image.Rgba – raw RGBA byte array
// image.Width – pixel width
// image.Height – pixel height
// image.Stride – bytes per row
// Encode back to PNG
byte[] output = ImageCodec.EncodeRgbaToPng(image);
File.WriteAllBytes("output.png", output);
The same pattern applies to JPEG:
DecodedImage image = ImageCodec.DecodeJpegToRgba(jpegBytes);
byte[] output = ImageCodec.EncodeRgbaToJpeg(image);
Codec methods
| Method | Description |
|---|---|
ImageCodec.DecodePngToRgba(byte[]) |
Decode a PNG byte array to RGBA pixels |
ImageCodec.EncodeRgbaToPng(DecodedImage) |
Encode RGBA pixels to a PNG byte array |
ImageCodec.DecodeJpegToRgba(byte[]) |
Decode a JPEG byte array to RGBA pixels |
ImageCodec.EncodeRgbaToJpeg(DecodedImage) |
Encode RGBA pixels to a JPEG byte array |
Filter pipeline
Filters can be chained via FilterPipeline and applied to a DecodedImage:
using ImageLib.Filter;
var pipeline = new FilterPipeline()
.Add(new BicubicResizeFilter(800, 600))
.Add(new GrayscaleFilter())
.Add(new GaussianBlurFilter(radius: 2));
DecodedImage result = pipeline.Apply(image);
Available filters
Resize / geometry
BicubicResizeFilter, BilinearResizeFilter, LanczosResizeFilter, NearestResizeFilter,
CropFilter, PadFilter, FlipFilter, Rotate90Filter
Colour / tone
AutoLevelsFilter, BrightnessContrastFilter, ColorMatrixFilter, CurvesFilter,
ExposureFilter, GammaFilter, GrayscaleFilter, HueRotateFilter,
InvertFilter, SaturationFilter, SepiaFilter, VibranceFilter, WhiteBalanceFilter
Blur / sharpen / morphology
BoxBlurFilter, GaussianBlurFilter, MedianFilter, UnsharpMaskFilter,
DilateFilter, ErodeFilter, OpenFilter, CloseFilter, SobelEdgeFilter, ThresholdFilter
Blending
BlendFilter, MultiplyBlendFilter, OverlayBlendFilter, ScreenBlendFilter
Native binaries
The package includes pre-built native libraries for:
| Platform | Library |
|---|---|
| Windows x64 | native/win-x64/imagewrap.dll |
| Linux x64 | native/linux-x64/libimagewrap.so |
| Linux arm64 | native/linux-arm64/libimagewrap.so |
These are copied to the output directory automatically and loaded at runtime via P/Invoke.
License
MIT — see LICENSE.