summaryrefslogtreecommitdiff
path: root/pictures.py
diff options
context:
space:
mode:
Diffstat (limited to 'pictures.py')
-rwxr-xr-xpictures.py52
1 files changed, 0 insertions, 52 deletions
diff --git a/pictures.py b/pictures.py
deleted file mode 100755
index dc93119..0000000
--- a/pictures.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import numpy as np
-import subprocess
-import json
-
-
-def descriptors(file):
- npy = os.path.join(
- os.path.dirname(file),
- ".meta",
- "descriptors",
- os.path.basename(os.path.splitext(file)[0]) + ".npy", # TODO
- )
- return np.load(npy, allow_pickle=False)
-
-
-mail = "pdp8@pdp8.info"
-cmd = "grep '3$' /home/ch/img/art/.meta/ratings|cut -f1"
-favs = subprocess.check_output(cmd, shell=True, text=True).splitlines()
-distances = {}
-for fav in favs:
- basename = os.path.basename(fav)
- # out = os.path.join("/home/ch/pub/pictures/", basename)
- out = os.path.join("/srv/www/pdp8-test/pictures/", basename)
- cmd = "convert '" + fav + "' -strip -resize 1024x '" + out + "'"
- os.system(cmd)
- cmd = (
- "exiv2 -M'set Xmp.dc.creator "
- + mail
- + "' -M'set Xmp.dc.rights © "
- + mail
- + "' -M'set Xmp.dc.license http://creativecommons.org/licenses/by-sa/4.0/' -M'set Xmp.xmpRights.UsageTerms Creative Commons Attribution-ShareAlike 4.0 International License' -M'set Xmp.xmpRights.Marked True' -M'set Xmp.dc.description Original artwork available from "
- + mail
- + "' "
- + out
- )
- os.system(cmd)
- """
- fav_d = descriptors(fav)
- distances[basename] = {}
- for img in favs:
- if fav != img:
- img_d = descriptors(img)
- sim = np.dot(fav_d, img_d) / (np.linalg.norm(fav_d) * np.linalg.norm(img_d))
- img_basename = os.path.basename(img)
- distances[basename][img_basename] = np.float64(1.0 - sim)
-with open("/home/ch/pub/distances.js", "w") as f:
- s = "distances = " + json.dumps(distances)
- print(s, file=f)
- """