SharpAstro.Webp
3.32.1561
dotnet add package SharpAstro.Webp --version 3.32.1561
NuGet\Install-Package SharpAstro.Webp -Version 3.32.1561
<PackageReference Include="SharpAstro.Webp" Version="3.32.1561" />
<PackageVersion Include="SharpAstro.Webp" Version="3.32.1561" />
<PackageReference Include="SharpAstro.Webp" />
paket add SharpAstro.Webp --version 3.32.1561
#r "nuget: SharpAstro.Webp, 3.32.1561"
#:package SharpAstro.Webp@3.32.1561
#addin nuget:?package=SharpAstro.Webp&version=3.32.1561
#tool nuget:?package=SharpAstro.Webp&version=3.32.1561
SharpAstro.Webp
Pure-managed WebP decoding for .NET 10, derived from RFC 6386 and RFC 9649.
The only encoder is lossless (VP8L): WebpEncoder.EncodeLossless / EncodeLosslessRgb /
EncodeLosslessGray, at its third rung (the four transforms, LZ77 backward references with the 2D distance codes, a colour cache
and meta prefix codes, each chosen per image by exact cost), with optional ICC/EXIF/XMP; WebpEncodeOptions.Effort 0 is literal-only, higher trades time for size. There is no lossy encoder.
Encode, at an effort from 0 (literal-only, fastest, largest) to 9 (slowest, smallest); the default is 6:
byte[] file = WebpEncoder.EncodeLossless(rgba, width, height, 0, new WebpEncodeOptions { Effort = 6 });
Measured against cwebp -lossless (libwebp 1.6.0) on 1080p inputs: effort 6 is 1.0-1.1x the size of cwebp's
default on photographic images and 0.84x on a screenshot, and takes about 6.5 s a photo against cwebp's 1.1 s
(6-13x slower). Effort 0 takes 30-45 ms and is 2-13x larger. Effort 9 is within 1% of cwebp -z 9 on a photo.
Size is not monotone in effort, so measure your own content if the last few percent matter. The
tables, and the benchmark and report that produce them, are in the repository's CODECS.md.
Every effort is bounded: the match finder's chain depth (2 to 512) and nice length (16 to 4096) are fixed per
effort, so a one-colour or all-distinct image costs no more per pixel than a photo; the working memory is
charged up front against a 1 GiB ceiling; dimensions over 16384, or over 2^26 pixels, are refused before
anything is allocated. A few seconds per megapixel at effort 6 and 20-30 s per 1080p image at effort 9 is what to budget.
Supported input includes VP8 lossy, VP8L lossless, ALPH transparency, and
animated WebP with full-canvas RGBA frames, random seeking, and frame timing.
ICC, EXIF, and XMP metadata are preserved. The SharpAstro.Codecs facade
decodes still images and returns frame 0 for animated WebP; use this package's
animation API to access the full timeline. Images larger than 67,108,864 pixels
are rejected to bound decoder allocations.
using SharpAstro.Webp;
byte[] data = File.ReadAllBytes("image.webp");
WebpImage image = WebpDecoder.Decode(data);
Console.WriteLine($"{image.Width} × {image.Height}");
Decode every frame into a full-canvas RGBA buffer:
WebpAnimation animation = WebpDecoder.DecodeAnimation(data);
foreach (WebpFrame frame in animation.Frames)
{
Console.WriteLine($"{frame.TimestampMs} ms: {frame.DurationMs} ms");
byte[] rgba = frame.Rgba;
}
For on-demand playback, seek to the next frame to produce, then decode it:
var decoder = new WebpAnimationDecoder(data);
decoder.Seek(12);
byte[] canvas = new byte[decoder.CanvasWidth * decoder.CanvasHeight * 4];
if (decoder.TryDecodeNextFrame(canvas, out WebpFrameInfo frameInfo))
{
Console.WriteLine($"Displayed frame {frameInfo.Index}");
}
The decoder is spec-derived from RFC 6386 / RFC 9649; libwebp/libvpx source was not consulted — their binaries are used only as test oracles. Written with AI assistance, whose training data may include libwebp.
Known oracle divergence: anim-vp8l-alpha-hint.webp has a VP8L animation frame
with transparent decoded pixels despite a cleared alpha_is_used hint. The
RFC 9649 blend flag requires alpha blending, which this decoder follows;
anim_dump 1.6.0 emits that frame uncomposited. It is excluded from the
anim_dump comparison but remains covered by compositing and
seek-versus-sequential tests.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- SharpAstro.Codecs.Abstractions (>= 3.32.1561)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SharpAstro.Webp:
| Package | Downloads |
|---|---|
|
SharpAstro.Codecs
Image-codec facade over the SharpAstro codec family: sniff a byte stream's format by its magic-byte signature and dispatch to the matching decoder (PNG, JPEG, TIFF, JPEG XR, OpenEXR, JPEG XL, JBIG2, JPEG 2000, WebP, GIF, Radiance RGBE, Netpbm PBM/PGM/PPM/PAM, BMP, and TGA by its TGA 2.0 footer, since a TGA has no leading magic number), returning a codec-neutral IDecodedImage (fidelity tier: native bit depth + ColorEncoding colour signalling, with a ToFloats() RGBA float32 view) or decoding zero-copy into a caller-provided 8-bit RGBA buffer (display tier, integer-sample formats). AOT-compatible. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.32.1561 | 33 | 11/3/2026 |
| 3.32.1541 | 30 | 11/3/2026 |
| 3.31.1511 | 27 | 11/3/2026 |
| 3.30.1461 | 26 | 11/3/2026 |
| 3.29.1431 | 27 | 11/3/2026 |
| 3.29.1401 | 34 | 11/3/2026 |
| 3.29.1361 | 33 | 11/3/2026 |
| 3.28.1341 | 29 | 11/3/2026 |
| 3.27.1311 | 30 | 11/3/2026 |
| 3.26.1281 | 29 | 11/3/2026 |
| 3.25.1261 | 31 | 11/3/2026 |
| 3.24.1241 | 250 | 11/3/2026 |
| 3.24.1231 | 26 | 11/2/2026 |
| 3.24.1221 | 1,537 | 10/27/2026 |
| 3.23.1201 | 2,698 | 10/25/2026 |
| 3.22.1171 | 414 | 10/25/2026 |
| 3.21.1151 | 58 | 10/25/2026 |
| 3.20.1121 | 42 | 10/25/2026 |
| 3.19.1091 | 44 | 10/24/2026 |