Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Computes and stores one or more perceptual hashes for all provided images. |
last modified: June 06, 2024
USAGE: phashes [-m method] [-d directory] [-t types] [-f file] [-s save] [-j jsonfile] [infile1 ... infileN]
-m ... methods ..... hash methods; one or more of: bmh, bdh, avh, pfh as a list of PURPOSE: To compute and store one or more perceptual hashes for all provided images.
DESCRIPTION: PHASHES will compute and store one or more perceptual hashes for all
provided images. If multiple images are provided, they can be listed in the
commmand line or obtained from a directory or they can be provided via a text file
containing a list one image per row using the -f option. There are four different
hashes that can be used: bmh (block mean hash), bdh (block difference hash),
avh (annular variance hash) and pfh (polar fft hash).
ARGUMENTS: -m methods ... hash METHODS. One or more of: bmh (block mean hash), bdh (block difference hash), avh (annular variance hash) and pfh (polar fft hash) as a list of comma separate values or "all". The default=bmh. -d directory ... optional path to DIRECTORY holding images. The default is no directory. The infiles have precedence over the directory. -t types ... limit of types of file formats to process from directory as a comma separate list. The default will process all files in the directory. This may not be a good idea if other than image files reside in the directory. -f file ... optional text FILE containing a list of paths to the input images with one image per row. The directory has precedence over the file. -s save ... SAVE the hash values to either the "comment" or "label" field in the image meta data. Choices are: comment (c), label (l) or neither/none (n). The default=comment -j jsonfile ... optional JSON FILE to hold list of images, methods and hash values. The jsonfile is a simple text file that can be used in addition to the save option. -p progress ... show PROGRESS to the terminal. The choices are: 0 (nothing), 1 (image only), 2 (image and method) or 3 (image, method and hash). The default=0. The output can be redirected to a tab delimited text file one row at a time that can be imported into Excel. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Example |
Original Images |
|
Command To Create And Store Perceptual Hashes |
Retrieve Lena Data Command
|
Retrieve Barn Data Command
|
Command To Create And Store Perceptual Hashes In JSON file As Well As In Image Comment Field |
JSON File Output { "PerceptualHashes":[ {"lena.png":[ {"method":"bmh", "phash":"1100111110111100110001111011110001000011111110000100001111101001010001111111100101001110011100110100100011100011010000011110011101000001010001110100000111000111010000011100111101000000110011110100000011001010010000001111111001000000111101000100000111110000"}, {"method":"bdh", "phash":"0110010001110110011101000111000101111001010010010101101101011011000110110011001100010011010100110101101101011010010111000111110000000011110000010101111001111011110010000000011001110001100011000110011010011011010010000001101010000111111101001000001110010000"}, {"method":"avh", "phash":"111111110000000000000111000011111111111110001111111111111111000010100000000000000000000000011111111110000000011111111111111111111111111100111100000000000000000000000000000000101110101111100000000000100000000000011111111111111111111111111111111111111111111"}, {"method":"pfh", "phash":"11111010111111101111111010111110101110101111111111010101011101011010101111111111111010110101101010101101101110011111111011111010010110110101011111101110101010101011011011111011101111111010111111111111101101111011111110111111"} ]}, {"barn.jpg":[ {"method":"bmh", "phash":"1111111111111111111111111111111111111111111111111111111111111111111111011111101101111100111101110000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000001111101000000000000000001110111100100000"}, {"method":"bdh", "phash":"1111000011010000110010001100101011011001110010010100110101101110101010101010101110011101100110100111000001111100010111001000010110111110011111110000110010100010000000000000000000000000000000000111000011110001111111111111111011000111111111111111111000000001"}, {"method":"avh", "phash":"111111111110111111111111111111111100000000111111111111111111111111111111111111111000000001111111111111110000111111111000000000000000000000011111000000000011111110000000011111111111111000000110111111111111111111000000111101000000000000011111111110011100000"}, {"method":"pfh", "phash":"11111101111111111111101111111111111101101111110101101101110110101010111101110111101011010110111010001011010111101011011111011010101101111101101101011011101101111111111111101111111111111101111111111111111111111111111111111111"} ]} ] } |