Calculate hash of image pixels

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Bilge
Posts: 9
Joined: 2012-09-05T12:53:29-07:00
Authentication code: 67789

Calculate hash of image pixels

Post by Bilge »

Is there a way to calculate a hash of the decoded image information only? That is, for two identical images with different metadata, the hash will be the same.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Calculate hash of image pixels

Post by magick »

ImageMagick already does this for you. Type 'identify -verbose myimage.png' for example.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Calculate hash of image pixels

Post by anthony »

Note tat this is only a hash of the image data. It ignores difference in meta-data (which will always be different due to file dates)

Also the slightest difference will produce a different hash. If the data may have slight differences (say from jpeg compressions), then a image comparision will probably be better for identical image testing.
http://www.imagemagick.org/Usage/compare/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Wolfgang Woehl
Posts: 34
Joined: 2010-02-25T15:22:50-07:00
Authentication code: 8675308

Re: Calculate hash of image pixels

Post by Wolfgang Woehl »

Anthony, in some use cases having a image-data-only hash is extremely useful. Now if the hash algorithm used was configurable ...
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Calculate hash of image pixels

Post by magick »

We have existing algorithms to support configurable hashes but so far we have not found a use case that justifies the distribution bloat. The default is SHA 256.
Post Reply