#!/bin/sh -e ## settings DIR="$(basename "$PWD")" TITLE="$(basename "$PWD" |sed 's/unlisted-//g' | cut -d"_" -f2- | tr '-' ' ')" PROCS="$(sysctl -n hw.ncpuonline)" mkdir -p thm mid echo "

$TITLE

" [ -f index.txt ] && cat index.txt echo "

" echo " " echo " " _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" 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 "

$TITLE

" > "${_file_html}" echo "

File: ${_file} (Open Original)

" >> "${_file_html}" echo "

\"Preview

" >> "${_file_html}" [ -f "${_file_descr}" ] && cat "${_file_descr}" >> "${_file_html}" echo "

Back to Index

" >> "${_file_html}" fi [ $_count -ne 0 ] \ && [ $(( _count % 3 )) -eq 0 ] \ && echo " " echo " " # increase file counter _count=$(( _count + 1)) while [ $(pgrep convert | wc -l) -gt $PROCS ] do sleep 0.3; done done # fill missing columns for i in $(( _count % 3 )) do echo " " done echo " " echo "
\"Thumbnail 
" echo "

" echo "

Back to the gallery index

" 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