This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Calculates an image's pixel hash as per the algorithm used by Danbooru | |
from pathlib import Path | |
import hashlib | |
from pyvips import Image, Error as VipsError | |
class DanbooruMediaFileImage: | |
"""Mimics Danbooru's MediaFile::Image, but for hash computation only. | |
See https://github.com/danbooru/danbooru/blob/bd0c6a37a81f851bd3e7862b97f7cf2fae7d5381/app/logical/media_file/image.rb |