During phash computation original image is resized. hashSize parameter basically controls height and width of resized image.

Algorithm can be found here. Implementation of the first step (reduce size):

image = image.convert("L").resize((hash_size, hash_size), Image.ANTIALIAS)

See sources of imagehash.phash


Lets see what the line imghash3.append(bin( int(imghash2, 16))[2:].zfill(64)) does.

In [16]: imghash2 = '11b97c7eb158ac'

First of all it converts hexadecimal string into integer

In [17]: int(imghash2, 16)
Out[17]: 4989018956716204

The builtin bin function is applied to convert the integer into a binary string

In [18]: bin( int(imghash2, 16))
Out[18]: '0b10001101110010111110001111110101100010101100010101100'

Drops first two characters using list slice

In [19]: bin( int(imghash2, 16))[2:]
Out[19]: '10001101110010111110001111110101100010101100010101100'

Adds 0 on the left side to make a string of 64 characters total

In [20]: bin( int(imghash2, 16))[2:].zfill(64)
Out[20]: '0000000000010001101110010111110001111110101100010101100010101100'
Answer from Konstantin on Stack Overflow
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 56956264 › why-wont-zfill-work-on-string-objects-in-python
Why won't zfill work on string objects in python? - Stack Overflow
July 9, 2019 - split_date.replace(date_section, date_section.zfill(2)) looks suspicious to me. Remember that str.replace does nothing unless you assign the result to something. ... As an aside, you should not be raising syntax errors here. ... Because it's not a syntax error, which implies an error in the python source code, which is encountered at compile time by the parser.
🌐
Stack Overflow
stackoverflow.com › questions › 72732261 › python-zfill-items-in-numpy-array-created-with-arange
Python: zfill items in numpy array created with arange - Stack Overflow
Now I want to make sure all numbers in all of the arrays are 6 digits in length. I want to accomplish this by using the zfill() function to add zeroes to the left of each number until they are 6 digits in length. But I can't figure out how to accomplish this.
🌐
W3Schools
w3schools.com › python › ref_string_zfill.asp
Python String zfill() Method
Python Examples Python Compiler ... Q&A Python Training ... The zfill() method adds zeros (0) at the beginning of the string, until it reaches the specified length....