Created
April 17, 2020 03:16
-
-
Save derekphilipau/41635530d777531b9264136a47b7f43c to your computer and use it in GitHub Desktop.
small hack to rename a file based on its dhash hex value
This file contains 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
import dhash | |
from PIL import Image | |
import shutil | |
import os | |
path1 = "images/" | |
path2 = "out/" | |
listing = os.listdir(path1) | |
for file in listing: | |
im = Image.open(path1 + file) | |
row, col = dhash.dhash_row_col(im) | |
shutil.copy(path1 + file, path2 + dhash.format_hex(row, col) + ".jpg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment