aboutsummaryrefslogtreecommitdiff
path: root/haunt/jakob/dynamic/import-images.sh
diff options
context:
space:
mode:
authorJakob L. Kreuze2023-02-12 14:50:42 -0500
committerJakob L. Kreuze2023-02-12 14:50:42 -0500
commit4b8de0bcf0ca598804a9d462933d492232b4b314 (patch)
treec0dc84333273faa56915f90b27865b2374679de4 /haunt/jakob/dynamic/import-images.sh
parent8e2abe9549360f37f6703bd995b8278e4fb6b291 (diff)
Merge branch 'self-hosted-comments'
It's been working well enough. I think it's time to get the initial version of this on `master'.
Diffstat (limited to 'haunt/jakob/dynamic/import-images.sh')
-rw-r--r--haunt/jakob/dynamic/import-images.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/haunt/jakob/dynamic/import-images.sh b/haunt/jakob/dynamic/import-images.sh
new file mode 100644
index 0000000..23f6130
--- /dev/null
+++ b/haunt/jakob/dynamic/import-images.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+VANITY="$1"
+shift
+
+for item in "$@"; do
+ filename=$(basename -- "$item")
+ extension="${filename##*.}"
+ filename="${filename%.*}"
+ uuid="$(uuidgen)"
+ cp "$item" "/home/jakob/gallery-images/$uuid.$extension"
+ convert "/home/jakob/gallery-images/$uuid.$extension" -thumbnail '100x100>' "/home/jakob/gallery-images/${uuid}_thumb.png"
+ psql jakob_gallery -c "INSERT INTO images (vanity, title, filename, thumb_filename, datetime) VALUES ('$VANITY', '$filename', '$uuid.$extension', '${uuid}_thumb.png', now());"
+done

© 2015 - 2026 Jakob L. Kreuze