def generate_hash(self):
"""Requests the image as found in `url` and generates a perceptual_hash from it"""
# This is slow: it has to get the image and spool it to a tempfile, then compute
# the hash
return None
# req = requests.get(self.url)
# if req.status_code == 200:
# buff = tempfile.SpooledTemporaryFile(max_size=1e9)
# downloaded = 0
# filesize = int(req.headers.get('content-length', 1000)) # Set a default length for the test client
# for chunk in req.iter_content():
# downloaded += len(chunk)
# buff.write(chunk)
# buff.seek(0)
# im = PillowImage.open(io.BytesIO(buff.read()))
# return str(imagehash.average_hash(im))
评论列表
文章目录