LegioSoft.Imaging.WebP
1.0.0-beta3
Prefix Reserved
dotnet add package LegioSoft.Imaging.WebP --version 1.0.0-beta3
NuGet\Install-Package LegioSoft.Imaging.WebP -Version 1.0.0-beta3
<PackageReference Include="LegioSoft.Imaging.WebP" Version="1.0.0-beta3" />
<PackageVersion Include="LegioSoft.Imaging.WebP" Version="1.0.0-beta3" />
<PackageReference Include="LegioSoft.Imaging.WebP" />
paket add LegioSoft.Imaging.WebP --version 1.0.0-beta3
#r "nuget: LegioSoft.Imaging.WebP, 1.0.0-beta3"
#:package LegioSoft.Imaging.WebP@1.0.0-beta3
#addin nuget:?package=LegioSoft.Imaging.WebP&version=1.0.0-beta3&prerelease
#tool nuget:?package=LegioSoft.Imaging.WebP&version=1.0.0-beta3&prerelease
LegioSoft.Imaging.WebP
WebP codec wrapper using native libwebp v1.6.0. High-performance WebP encoding and decoding with support for multiple color formats.
Installation
dotnet add package LegioSoft.Imaging.WebP
Features
- Encoding - RGBA, RGB, BGRA, BGR formats with lossless/lossy compression
- Decoding - Multiple colorspaces (RGBA, RGB, BGRA, BGR, ARGB)
- Transformation - Scale, crop, and flip images during encoding/decoding
- Advanced Options - Fine-tune compression quality, method, filters, and alpha settings
- Metadata - Extract image dimensions, alpha channel, animation, and format type
- Cross-Platform - Windows, Linux, macOS native library support
Core Classes
WebPImage- High-level static API for encoding, decoding, and transformationsWebPEncoder- Low-level encoder with advanced optionsWebPDecoder- Low-level decoder with scaling, cropping, and flip supportWebPEncodeOptions- Advanced encoding configuration (quality, method, filters, alpha)WebPInfo- WebP image metadata (width, height, format, alpha, animation)WebPValidationHelper- WebP format validation
Usage
Basic Encoding
using LegioSoft.Imaging.WebP;
// Encode RGBA data to WebP
byte[] rgbaData = File.ReadAllBytes("image.rgba");
byte[] webpData = WebPImage.Encode(rgbaData, width, height, quality: 75);
// Encode with lossless compression
byte[] lossless = WebPImage.EncodeLossless(rgbaData, width, height);
// Encode RGB data
byte[] rgbData = File.ReadAllBytes("image.rgb");
byte[] webpData = WebPImage.EncodeRGB(rgbData, width, height, quality: 80);
Advanced Encoding
var options = new WebPEncodeOptions
{
Quality = 80.0f,
Lossless = false,
Method = 6,
FilterStrength = 60,
Autofilter = true,
AlphaQuality = 90
};
byte[] webpData = WebPImage.EncodeAdvanced(rgbaData, width, height, options);
Basic Decoding
// Decode WebP to RGBA
byte[] webpData = File.ReadAllBytes("image.webp");
byte[] rgbaData = WebPImage.Decode(webpData);
// Decode with specific colorspace
byte[] bgrData = WebPImage.Decode(webpData, WEBP_CSP_MODE.MODE_BGR);
// Decode from file or stream
byte[] data = WebPImage.Decode("image.webp");
using var stream = File.OpenRead("image.webp");
byte[] data = WebPImage.Decode(stream);
Decoding with Transformations
// Scale during decode
byte[] scaled = WebPImage.Scale(webpData, 640, 480);
// Crop during decode
byte[] cropped = WebPImage.Crop(webpData, cropX: 10, cropY: 10, cropWidth: 200, cropHeight: 200);
// Flip vertically during decode
byte[] flipped = WebPImage.Flip(webpData);
Image Info
WebPInfo info = WebPImage.GetInfo(webpData);
Console.WriteLine($"Dimensions: {info.Width}x{info.Height}");
Console.WriteLine($"Has Alpha: {info.HasAlpha}");
Console.WriteLine($"Animated: {info.HasAnimation}");
Console.WriteLine($"Format: {info.Format}");
Encoding with Transformations
// Encode with scaling
byte[] scaled = WebPImage.EncodeWithScaling(rgbaData, width, height, targetWidth: 640, targetHeight: 480);
// Encode with cropping
byte[] cropped = WebPImage.EncodeWithCropping(rgbaData, width, height, cropX: 10, cropY: 10, cropWidth: 200, cropHeight: 200);
Validation
byte[] imageData = File.ReadAllBytes("file.webp");
bool isValidWebP = WebPImage.IsValidWebP(imageData);
Version Info
string version = WebPImage.GetVersion();
Console.WriteLine($"libwebp version: {version}");
Encoding Options
WebPEncodeOptions provides advanced control:
- Preset - DEFAULT, PICTURE, PHOTO, DRAWING, ICON, TEXT
- Quality - 0-100 quality level
- Lossless - Enable lossless compression
- Method - 0-6 (faster to better compression)
- ImageHint - DEFAULT, PICTURE, PHOTO, GRAPH
- FilterStrength - 0-100 filter strength
- FilterSharpness - 0-7 filter sharpness
- Autofilter - Enable automatic filter adjustment
- AlphaCompression - 0-1 alpha compression mode
- AlphaFiltering - 0-2 alpha filtering
- AlphaQuality - 0-100 alpha channel quality
Platform Support
- .NET 6.0, 7.0, 8.0, 9.0, 10.0
- Windows (x64)
- Linux (x64, ARM64)
- macOS (supported via native library)
Dependencies
- LegioSoft.Imaging.Core - Core interfaces and types
- libwebp v1.6.0 native library (included)
License
Apache License 2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- LegioSoft.Imaging.Core (>= 1.0.0-beta3)
-
net6.0
- LegioSoft.Imaging.Core (>= 1.0.0-beta3)
-
net7.0
- LegioSoft.Imaging.Core (>= 1.0.0-beta3)
-
net8.0
- LegioSoft.Imaging.Core (>= 1.0.0-beta3)
-
net9.0
- LegioSoft.Imaging.Core (>= 1.0.0-beta3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta3 | 63 | 1/10/2026 |
1.0.0-beta3 - Initial beta release of LegioSoft.Imaging.WebP.
Features:
- WebP encoding (RGBA, RGB, BGRA, BGR formats) with proper memory management
- WebP decoding with multiple colorspaces
- Lossless and lossy compression modes
- Advanced encoding options (method, filter, alpha, etc.)
- Image transformation (scale, crop, flip)
- WebP metadata extraction (width, height, alpha, animation)
- Cross-platform native library support (Windows, Linux, macOS)
- ILegioImageEncoder and ILegioImageDecoder interface implementation
- Support for .NET 6.0, 7.0, 8.0, 9.0, and 10.0
- Updated to libwebp 1.6.0 ABI version (0x0210)
- Fixed memory leaks with proper WebPMemoryWriterClear calls
- Refactored to 1 class = 1 file structure