diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2021-11-19 23:55:13 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2021-11-19 23:55:13 +0300 |
| commit | 79a4e6c60f2a6b6b69f464a6c83f83e42e5ea510 (patch) | |
| tree | 4033484cff53f3a652a38f35086771b1772ec73d /visual/thumbs.sh | |
| parent | 1cae377e2f6198b4df5326a820b6fc3e30486b16 (diff) | |
| download | aaoth.xyz-79a4e6c60f2a6b6b69f464a6c83f83e42e5ea510.tar.gz aaoth.xyz-79a4e6c60f2a6b6b69f464a6c83f83e42e5ea510.zip | |
rename art to visual
'cause it makes more sense. also, this action made me realize that
my website is very poorly designed, because to just rename one page
i needed to make changes in 6 different files! that's really gross...
i hope i can improve it.
Diffstat (limited to 'visual/thumbs.sh')
| -rwxr-xr-x | visual/thumbs.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/visual/thumbs.sh b/visual/thumbs.sh new file mode 100755 index 0000000..3c1a633 --- /dev/null +++ b/visual/thumbs.sh @@ -0,0 +1,60 @@ +#!/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 + + mkdir -p "$_thumbs_dir" + + _imgs="$(find . -maxdepth 1 \ + -iname "*.jpg" -or \ + -iname "*.jpeg" -or \ + -iname "*.gif" -or \ + -iname "*.png" -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 + |
