Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3    Statistic    FMM    Blog  

GMImage.Hash

Calculates a hash of the image.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 9.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.Hash"; ImageRef )   More

Parameters

Parameter Description Example
ImageRef The image reference number. 1

Result

Returns text or error.

Description

Calculates a hash of the image.
Hash is returned as 64 characters being 1 or 0.
We convert image to 8x8, turn grayscale and check if pixels are above or below mean value.
This hash is quite immune against resizing, compression artifacts and hue changes.
You can use Text.LevenshteinDistance or Text.JaroWinklerDistance to compare two hashes.

While GMImage.Hash does make a finger print, you can use Hash.Digest to get a hash of the image bytes.

Examples

Play with hash function:

Set Variable [ $ImageRef ; Value: MBS("GMImage.NewFromContainer"; Test::BigImage) ]
Set Variable [ $Hash1 ; Value: MBS("GMImage.Hash"; $ImageRef) ]
Set Variable [ $r ; Value: MBS( "GMImage.Flip"; $ImageRef ) ]
Set Variable [ $Hash2 ; Value: MBS("GMImage.Hash"; $ImageRef) ]
Set Variable [ $r ; Value: MBS( "GMImage.Flop"; $ImageRef ) ]
Set Variable [ $Hash3 ; Value: MBS("GMImage.Hash"; $ImageRef) ]
Set Variable [ $Error ; Value: MBS("GMImage.Release"; $ImageRef) ]
Show Custom Dialog [ "Hash original: " & $hash1 & ¶ & "Hash after 1x mirror: " & $hash2 & ¶ & "Hash after 2x mirror: " &… ]

See also

Release notes

Blog Entries

Created 10th September 2019, last changed 16th April 2021


GMImage.GetcolorMap - GMImage.ImageCount

Feedback: Report problem or ask question.




Links
MBS Xojo tutorial videos

Start Chat