AlanNevill.ImageSharp.ImageHash 1.4.4-alpha

This is a prerelease version of AlanNevill.ImageSharp.ImageHash.
dotnet add package AlanNevill.ImageSharp.ImageHash --version 1.4.4-alpha                
NuGet\Install-Package AlanNevill.ImageSharp.ImageHash -Version 1.4.4-alpha                
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="AlanNevill.ImageSharp.ImageHash" Version="1.4.4-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AlanNevill.ImageSharp.ImageHash --version 1.4.4-alpha                
#r "nuget: AlanNevill.ImageSharp.ImageHash, 1.4.4-alpha"                
#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.
// 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 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. 
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.4.4-alpha 66 6/19/2024