91 lines
2.5 KiB
Bash
91 lines
2.5 KiB
Bash
|
#!/bin/sh -e
|
||
|
|
||
|
## settings
|
||
|
|
||
|
DIR="$(basename "$PWD")"
|
||
|
TITLE="$(basename "$PWD" |sed 's/unlisted-//g' | cut -d"_" -f2- | tr '-' ' ')"
|
||
|
|
||
|
mkdir -p thm mid
|
||
|
|
||
|
echo "<h1>$TITLE</h1>"
|
||
|
[ -f index.txt ] && cat index.txt
|
||
|
|
||
|
echo "<p>"
|
||
|
echo "<table class=\"photo-table\">"
|
||
|
echo "<tr>"
|
||
|
|
||
|
_count=0
|
||
|
find * -maxdepth 0 -mindepth 0 -type f \( -iname "*.jpg" \
|
||
|
-o -iname "*.jpeg" \
|
||
|
-o -iname "*.png" \
|
||
|
-o -iname "*.gif" \
|
||
|
\) \
|
||
|
| sort -r | while read _file
|
||
|
do
|
||
|
_file_thm="thm/${_file%%.*}.jpg"
|
||
|
_file_mid="mid/${_file%%.*}.jpg"
|
||
|
_file_html="${_file%%.*}.html"
|
||
|
_file_descr="${_file%%.*}.txt"
|
||
|
|
||
|
# increase file counter
|
||
|
_count=$(( _count + 1))
|
||
|
|
||
|
if [ ! -f "${_file_thm}" ]
|
||
|
then
|
||
|
convert -quality 73 \
|
||
|
-sharpen 2x2 \
|
||
|
-auto-orient \
|
||
|
-define jpeg:size=440x440 \
|
||
|
"$_file" \
|
||
|
-thumbnail 220x220^ \
|
||
|
-gravity center \
|
||
|
-extent 220x220 \
|
||
|
"${_file_thm}" \
|
||
|
>/dev/null 2>&1 &
|
||
|
fi
|
||
|
|
||
|
if [ ! -f "${_file_mid}" ]
|
||
|
then
|
||
|
convert -quality 83 \
|
||
|
-sharpen 2x2 \
|
||
|
-auto-orient \
|
||
|
-define jpeg:size=1440x2400 \
|
||
|
"$_file" \
|
||
|
-thumbnail 720x1600 \
|
||
|
"${_file_mid}" \
|
||
|
>/dev/null 2>&1 &
|
||
|
fi
|
||
|
if [ ! -f "${_file_html}" ]
|
||
|
then
|
||
|
echo "<h1>$TITLE</h1>" > "${_file_html}"
|
||
|
echo "<p>File: ${_file} (<a href=\"/photos/$DIR/${_file}\" target=_blank>Open Original</a>)</p>" >> "${_file_html}"
|
||
|
echo "<p><img class=\"photo-mid\" src=\"/photos/$DIR/${_file_mid}\"></p>" >> "${_file_html}"
|
||
|
[ -f "${_file_descr}" ] && cat "${_file_descr}" >> "${_file_html}"
|
||
|
echo "<p><a href=index.html>Back to Index</a></p>" >> "${_file_html}"
|
||
|
fi
|
||
|
|
||
|
echo "<td class=\"photo-td\" ><a href=\"/photos/$DIR/${_file_html}\"><img class=\"photo-img\" src=\"${_file_thm}\"></a></td>"
|
||
|
if [ $(( _count % 3 )) -eq 0 ]
|
||
|
then
|
||
|
echo "</tr><tr>"
|
||
|
fi
|
||
|
|
||
|
while [ $(pgrep convert | wc -l) -ge 15 ]
|
||
|
do sleep 0.3; done
|
||
|
|
||
|
done
|
||
|
echo "</tr>"
|
||
|
echo "</table>"
|
||
|
echo "</p>"
|
||
|
|
||
|
echo "<p><a href=../index.html>Back to the gallery index</a></p>"
|
||
|
echo "section: photos" > dir.meta
|
||
|
|
||
|
wait
|
||
|
|
||
|
# it looks like wait doesn't catch processes spawned
|
||
|
# in a subshell. So we check explicitely for running
|
||
|
# convert processes. XXX
|
||
|
while [ $(pgrep convert | wc -l) -ge 1 ]
|
||
|
do sleep 1; done
|