AlanNevill.ImageSharp.ImageHash
1.4.4-alpha
dotnet add package AlanNevill.ImageSharp.ImageHash --version 1.4.4-alpha
NuGet\Install-Package AlanNevill.ImageSharp.ImageHash -Version 1.4.4-alpha
<PackageReference Include="AlanNevill.ImageSharp.ImageHash" Version="1.4.4-alpha" />
paket add AlanNevill.ImageSharp.ImageHash --version 1.4.4-alpha
#r "nuget: AlanNevill.ImageSharp.ImageHash, 1.4.4-alpha"
// Install AlanNevill.ImageSharp.ImageHash as a Cake Addin #addin nuget:?package=AlanNevill.ImageSharp.ImageHash&version=1.4.4-alpha&prerelease // Install AlanNevill.ImageSharp.ImageHash as a Cake Tool #tool nuget:?package=AlanNevill.ImageSharp.ImageHash&version=1.4.4-alpha&prerelease
ImageHash
Perceptual image hashing using the ImageSharp library. Includes three hashing algorithms (AverageHash, DifferenceHash, and PerceptualHash). See github for more information.
Calculate image hash
<a id='snippet-CalculateImageHash'></a>
var hashAlgorithm = new AverageHash();
// or one of the other available algorithms:
// var hashAlgorithm = new DifferenceHash();
// var hashAlgorithm = new PerceptualHash();
string filename = "your filename";
using var stream = File.OpenRead(filename);
ulong imageHash = hashAlgorithm.Hash(stream);
<sup><a href='/tests/ImageHash.Test/Examples.cs#L14-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-CalculateImageHash' title='Start of snippet'>anchor</a></sup>
Calculate image similarity
Note that to calculate the image similarity, both image hashes should have been calculated using the same hash algorihm.
<a id='snippet-CalculateSimilarity'></a>
// calculate the two image hashes
ulong hash1 = hashAlgorithm.Hash(imageStream1);
ulong hash2 = hashAlgorithm.Hash(imageStream2);
double percentageImageSimilarity = CompareHash.Similarity(hash1, hash2);
<sup><a href='/tests/ImageHash.Test/Examples.cs#L35-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-CalculateSimilarity' title='Start of snippet'>anchor</a></sup>
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. |
-
net8.0
- SixLabors.ImageSharp (>= 3.1.4)
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.4.4-alpha | 70 | 6/19/2024 |