Meziantou.Framework.SnapshotTesting.ImageSharp
2.0.7
Prefix Reserved
See the version list below for details.
dotnet add package Meziantou.Framework.SnapshotTesting.ImageSharp --version 2.0.7
NuGet\Install-Package Meziantou.Framework.SnapshotTesting.ImageSharp -Version 2.0.7
<PackageReference Include="Meziantou.Framework.SnapshotTesting.ImageSharp" Version="2.0.7" />
<PackageVersion Include="Meziantou.Framework.SnapshotTesting.ImageSharp" Version="2.0.7" />
<PackageReference Include="Meziantou.Framework.SnapshotTesting.ImageSharp" />
paket add Meziantou.Framework.SnapshotTesting.ImageSharp --version 2.0.7
#r "nuget: Meziantou.Framework.SnapshotTesting.ImageSharp, 2.0.7"
#:package Meziantou.Framework.SnapshotTesting.ImageSharp@2.0.7
#addin nuget:?package=Meziantou.Framework.SnapshotTesting.ImageSharp&version=2.0.7
#tool nuget:?package=Meziantou.Framework.SnapshotTesting.ImageSharp&version=2.0.7
Meziantou.Framework.SnapshotTesting.ImageSharp
Meziantou.Framework.SnapshotTesting.ImageSharp extends Meziantou.Framework.SnapshotTesting with support for SixLabors.ImageSharp images, enabling snapshot validation of Image objects stored as PNG, JPEG, BMP, TIFF, or WebP files.
Licensing
This package is MIT-licensed, but it takes a hard dependency on
SixLabors.ImageSharp, which since v3 is published under the
Six Labors Split License: AGPL-3.0 unless you
hold a commercial licence. Installing this package therefore brings that obligation with it, and your build
will emit a "No Six Labors license found" warning until you set SixLaborsLicenseKey, set
SixLaborsLicenseFile, or add a sixlabors.lic file.
If that does not suit your project,
Meziantou.Framework.SnapshotTesting.SkiaSharp
offers the same image snapshot support on top of SkiaSharp, which is MIT-licensed.
Setup
Call AddImageSharp() on your SnapshotSettings to register the ImageSharp serializer and comparer:
using System.Runtime.CompilerServices;
using Meziantou.Framework.SnapshotTesting;
using Meziantou.Framework.SnapshotTesting.ImageSharp;
internal static class SnapshotConfiguration
{
[ModuleInitializer]
internal static void Initialize()
{
SnapshotSettings.Default.AddImageSharp();
}
}
Then validate images from your tests:
public sealed class SampleTests
{
[Fact]
public void ValidateImage()
{
using var image = Image.Load("sample.png");
Snapshot.Validate(image, SnapshotType.Png);
}
}
Register once for the whole test assembly, not inside a test method. SnapshotSettings.Default is
shared by every test in the process and its collections are not safe for concurrent modification, so
calling AddImageSharp() from a test races against any other test that is serializing a snapshot at
the same time. Repeated calls also append a serializer and a converter every time.
Image comparison
By default, images are compared pixel-by-pixel (exact comparison). To allow minor rendering differences, configure a Structural Similarity Index (SSIM) threshold:
// In the module initializer shown above
SnapshotSettings.Default.AddImageSharp(new ImageComparisonSettings
{
SimilarityThreshold = 0.99f, // 0.0 = completely different, 1.0 = identical
});
When SimilarityThreshold is set, the mean SSIM across the R, G, and B channels is computed and must be greater than or equal to the threshold for the images to be considered equal.
| 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. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.SnapshotTesting (>= 3.1.3)
- SixLabors.ImageSharp (>= 4.1.0)
-
net11.0
- Meziantou.Framework.SnapshotTesting (>= 3.1.3)
- SixLabors.ImageSharp (>= 4.1.0)
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 |
|---|---|---|
| 2.0.9 | 37 | 9/6/2026 |
| 2.0.8 | 38 | 9/3/2026 |
| 2.0.7 | 45 | 9/3/2026 |
| 2.0.6 | 89 | 8/30/2026 |
| 2.0.5 | 88 | 8/29/2026 |
| 2.0.4 | 84 | 8/23/2026 |
| 2.0.3 | 101 | 8/16/2026 |
| 2.0.2 | 97 | 8/9/2026 |
| 2.0.1 | 121 | 7/8/2026 |
| 2.0.0 | 113 | 7/5/2026 |
| 1.0.16 | 109 | 7/5/2026 |
| 1.0.15 | 123 | 6/28/2026 |
| 1.0.14 | 121 | 6/22/2026 |
| 1.0.13 | 126 | 6/14/2026 |
| 1.0.12 | 109 | 6/13/2026 |
| 1.0.11 | 106 | 6/13/2026 |
| 1.0.10 | 127 | 6/7/2026 |
| 1.0.9 | 108 | 5/31/2026 |
| 1.0.8 | 120 | 5/24/2026 |
| 1.0.7 | 117 | 5/23/2026 |