models.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:open-ledger 作者: creativecommons 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号