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
                    
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="Webp-Wrapper-for-NET-Win-x64" Version="1.6.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Webp-Wrapper-for-NET-Win-x64" Version="1.6.5" />
                    
Directory.Packages.props
<PackageReference Include="Webp-Wrapper-for-NET-Win-x64" />
                    
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 Webp-Wrapper-for-NET-Win-x64 --version 1.6.5
                    
#r "nuget: Webp-Wrapper-for-NET-Win-x64, 1.6.5"
                    
#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 Webp-Wrapper-for-NET-Win-x64@1.6.5
                    
#: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=Webp-Wrapper-for-NET-Win-x64&version=1.6.5
                    
Install as a Cake Addin
#tool nuget:?package=Webp-Wrapper-for-NET-Win-x64&version=1.6.5
                    
Install as a Cake Tool

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 NuGet NuGet
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.6.5 108 7/26/2026
1.6.4 369 11/23/2025
1.6.2 352 11/11/2025
1.6.1 337 11/3/2025
1.6.0 257 8/22/2025
1.0.7 355 6/24/2025
1.0.6 296 5/19/2025
1.0.5 284 4/23/2025

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