Verify.ImageHash
Extends Verify to allow comparison of images via ImageHash.
Install / Use
/learn @VerifyTests/Verify.ImageHashREADME
<img src="/src/icon.png" height="30px"> Verify.ImageHash
Extends Verify to allow comparison of images via ImageHash.<!-- singleLineInclude: intro. path: /docs/intro.include.md -->
See Milestones for release notes.
Contains comparers for png, jpg, and bmp.
Sponsors
Entity Framework Extensions<!-- include: sponsors. path: /docs/sponsors.include.md -->
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
NuGet
- https://nuget.org/packages/Verify.ImageHash
Usage
<!-- snippet: enable --><a id='snippet-enable'></a>
[ModuleInitializer]
public static void Init() =>
VerifyImageHash.Initialize();
<sup><a href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-enable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Image Comparers
The following will use ImageHash to compare the images instead of the default DifferenceHash algorithm.
<!-- snippet: CompareImage --><a id='snippet-CompareImage'></a>
[Test]
public Task CompareImage() =>
VerifyFile("sample.jpg");
<sup><a href='/src/Tests/Samples.cs#L6-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompareImage' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Register all comparers
All comparers can be registered:
VerifyImageHash.RegisterComparers();
Use specific threshold
<!-- snippet: CompareImageThreshold --><a id='snippet-CompareImageThreshold'></a>
[Test]
public Task CompareImageThreshold() =>
VerifyFile("sample.jpg")
.UseImageHash(threshold: 85);
<sup><a href='/src/Tests/Samples.cs#L14-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompareImageThreshold' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Use specific algorithm
<!-- snippet: CompareImageAlgorithm --><a id='snippet-CompareImageAlgorithm'></a>
[Test]
public Task CompareImageAlgorithm() =>
VerifyFile("sample.jpg")
.UseImageHash(algorithm: new PerceptualHash());
<sup><a href='/src/Tests/Samples.cs#L23-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompareImageAlgorithm' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Icon
Swirl designed by Philipp Petzka from The Noun Project.
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.6kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

