diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2021-05-27 00:13:05 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2021-05-27 00:19:10 +0300 |
| commit | 324991d82ef26798ed5842a6fe03eabc798ff497 (patch) | |
| tree | 8097dad5a93e283e42e7b4a1e0491d389b912c76 /art | |
| parent | 3e30c7241cb18c5e02195e889b9e4dc73490214a (diff) | |
| download | aaoth.xyz-324991d82ef26798ed5842a6fe03eabc798ff497.tar.gz aaoth.xyz-324991d82ef26798ed5842a6fe03eabc798ff497.zip | |
modify art page to display thumbnails
thumbnails are currently created using shell script and require
imagemagick installed on the server. i know it's stupid, but i think
that including thumbnails to repo is also stupid.
maybe later i replace this script with actual jekyll plugin, but for
this i'll need to familiarize myself with ruby.
but now i use following addition to the git hook on the server:
```
[ -f "$TMP_GIT_CLONE/art/thumbs.sh" ] && {
dir="$PWD"
cd "$TMP_GIT_CLONE/art/" && sh thumbs.sh && cd "$dir"
}
```
it happens after cloning to remote repo and before building with bundle.
overall, this is a bodge now, it recompiles all thumbnails every time
due to quirks in my current setup.
Diffstat (limited to 'art')
| -rw-r--r-- | art/photos/pyramid.jpg | bin | 2578973 -> 2628562 bytes | |||
| -rwxr-xr-x | art/thumbs.sh | 56 |
2 files changed, 56 insertions, 0 deletions
diff --git a/art/photos/pyramid.jpg b/art/photos/pyramid.jpg Binary files differindex d439f6f..5524a91 100644 --- a/art/photos/pyramid.jpg +++ b/art/photos/pyramid.jpg diff --git a/art/thumbs.sh b/art/thumbs.sh new file mode 100755 index 0000000..758b0a9 --- /dev/null +++ b/art/thumbs.sh @@ -0,0 +1,56 @@ +#!/bin/sh -ex + +_img_dirs="$( find . -maxdepth 1 -type d | sed -e '1d' -e 's/^\.\///' )" +_thumb_size="835x" +_thumbs_dir="thumbs" +_force_render=0 + +usage() { + echo "usage: $0 [-f|--force]" +} + +[ -n "$1" ] && \ + case $1 in + -f|--force) + _force_render=1 + ;; + -h|--help) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; + esac + +for dir in $_img_dirs +do + cd "./$dir" || exit 1 + + [ -d "$_thumbs_dir" ] || mkdir "$_thumbs_dir" + + _imgs="$(find . -maxdepth 1 -type f | cut -b 3-)" + for _img in $_imgs + do + _ext="${_img##*.}" + _name="${_img%%.*}" + _thumb="./$_thumbs_dir/${_name}_thumb.${_ext}" + + [ "$_force_render" -eq 1 ] || [ ! -f "$_thumb" ] && \ + { + # when compressed, gifs look ugly, so just copy them + # i know this is bad, but i'll adress it later + [ "$_ext" = "gif" ] && \ + echo "copied $1 to $_thumb" && \ + cp "$_img" "$_thumb" && continue + + echo "creating thumbnail for $_name..." + convert "$_img" -resize "$_thumb_size" "$_thumb" + } + done + + cd ".." + +done + |
