I'm using a tool called "exiftool" to extract a binary JPG from a file. I would like to then compute a sha512 sum from that file. What is a good way to do this?
My function to extract the binary JPG is as follows:
def getVisSig(filename):
""" Calculates visual signature using
imagemagick package. returns signature
"""
print("Calculating VisSig on %s" % filename)
result = subprocess.Popen(["exiftool","-b","-PreviewImage",
filename,], stdout=subprocess.PIPE)
The output is binary. How should I handle this to compute a sha512 sum? I was thinking I could pipe the output to sha512sum in the command line and read the resulting string into Python, but not sure if there is a better way?