Webp-Wrapper-for-NET-Win-x64
1.6.5
dotnet add package Webp-Wrapper-for-NET-Win-x64 --version 1.6.5
NuGet\Install-Package Webp-Wrapper-for-NET-Win-x64 -Version 1.6.5
<PackageReference Include="Webp-Wrapper-for-NET-Win-x64" Version="1.6.5" />
<PackageVersion Include="Webp-Wrapper-for-NET-Win-x64" Version="1.6.5" />
<PackageReference Include="Webp-Wrapper-for-NET-Win-x64" />
paket add Webp-Wrapper-for-NET-Win-x64 --version 1.6.5
#r "nuget: Webp-Wrapper-for-NET-Win-x64, 1.6.5"
#:package Webp-Wrapper-for-NET-Win-x64@1.6.5
#addin nuget:?package=Webp-Wrapper-for-NET-Win-x64&version=1.6.5
#tool nuget:?package=Webp-Wrapper-for-NET-Win-x64&version=1.6.5
This fork is intended for current versions of .NET. Includes the latest version of the library libwebp.dll v1.6.0. The structures have been updated to match the current version of the library.
The wrapper work only 64-bit Windows system.
| Package | Download |
|---|---|
| Webp-Wrapper-for-NET-Win-x64 |
dotnet add package Webp-Wrapper-for-NET-Win-x64
WebP-wrapper
Wrapper for libwebp in C#. The most complete wrapper in pure managed C#.
Exposes Simple Decoding and Encoding API, Advanced Decoding and Encoding API (with statistics of compression), Get version library and WebPGetFeatures (info of any WebP file). Exposed get PSNR, SSIM or LSIM distortion metrics.
The wrapper is in safe managed code in one class. No need for external dll except libwebp_x64.dll (included). The wrapper work only 64-bit Windows system.
Decompress Functions:ap bmp = webp.Load("test.webp");
Decode WebP to bitmap
byte[] rawWebp = File.ReadAllBytes("test.webp");
using Bitmap bmp = WebP.Decode(rawWebp);
Advanced decode WebP to bitmap
byte[] rawWebp = File.ReadAllBytes("test.webp");
using Bitmap bmp = WebP.Decode(rawWebp, new WebPDecoderOptions { UseThreads = true, Flip = true });
Compress Functions:
Encode to memory buffer in lossy mode with quality 75 and save to file
byte[] rawJpg = File.ReadAllBytes("test.jpg");
using MemoryStream memoryStream = new MemoryStream(rawJpg);
using Bitmap bmp = new Bitmap(memoryStream);
byte[] rawWebp = WebP.EncodeLossy(bmp, 75);
File.WriteAllBytes("test.webp", rawWebp);
Encode to memory buffer in lossless mode and save to file
byte[] rawJpg = File.ReadAllBytes("test.jpg");
using MemoryStream memoryStream = new MemoryStream(rawJpg);
using Bitmap bmp = new Bitmap(memoryStream);
byte[] rawWebp = WebP.EncodeLossless(bmp);
File.WriteAllBytes("test.webp", rawWebp);
Encode to memory buffer in lossy with custom config and save to file
WebP.WebPConfigInit(WebPPreset.WEBP_PRESET_PHOTO, 85, out WebPConfig config);
config.Method = 6;
config.Pass = 2;
config.ThreadLevel = true;
byte[] rawJpg = File.ReadAllBytes("test.jpg");
using MemoryStream memoryStream = new MemoryStream(rawJpg);
using Bitmap bmp = new Bitmap(memoryStream);
byte[] rawWebp = WebP.Encode(bmp, config);
File.WriteAllBytes("test.webp", rawWebp);
Another Functions:
Get version of libwebp.dll
string version = "libwebp.dll v" + WebP.GetVersion();
Get info from WebP file
byte[] rawWebp = File.ReadAllBytes("test.webp");
WebPBitstreamFeatures info = WebP.GetInfo(rawWebp);
Console.WriteLine("Width: " + info.Width + "\n" +
"Height: " + info.Height + "\n" +
"Has alpha: " + info.HasAlpha + "\n" +
"Is animation: " + info.HasAnimation + "\n" +
"Format: " + info.Format);
Get PSNR, SSIM or LSIM distortion metric between two pictures
int metric = 0; //0 = PSNR, 1= SSIM, 2=LSIM
using Bitmap source = (Bitmap) Image.FromFile("image1.png");
using Bitmap reference = (Bitmap) Image.FromFile("image2.png");
float[] result = WebP.GetPictureDistortion(source, reference, metric);
Console.WriteLine("Red: " + result[0] + "dB\n" +
"Green: " + result[1] + "dB\n" +
"Blue: " + result[2] + "dB\n" +
"Alpha: " + result[3] + "dB\n" +
"All: " + result[4] + "dB\n");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- System.Drawing.Common (>= 10.0.10)
-
net8.0
- System.Drawing.Common (>= 10.0.10)
-
net9.0
- System.Drawing.Common (>= 10.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.6.5: BREAKING CHANGES. The wrapper API has been completely redesigned and is no longer compatible with the old code (see the README). The code has been rewritten, and critical and minor issues have been fixed.
1.6.3: Replacing DllImport with LibraryImport
1.6.2: Added .NET 10
1.6.1: Fixed a memory allocation error for large images in the lossy encoding method
1.6.0: libwebp.dll v1.6.0
1.0.7: Performance optimization
1.0.6: .NET 9.0, .NET 8.0, libwebp.dll v1.5.0
1.0.5: .NET 9.0, libwebp.dll v1.5.0