Fix cache file detection
This commit is contained in:
parent
98dad294a1
commit
7f6d35f9b8
@ -16,7 +16,10 @@ ROW_HEIGHT=150 # how high will the justified rows be?
|
|||||||
THUMB_QUALITY=83 # quality for thumbnails
|
THUMB_QUALITY=83 # quality for thumbnails
|
||||||
THUMB_PATH="thm" # relative path to thumbnail folder
|
THUMB_PATH="thm" # relative path to thumbnail folder
|
||||||
THUMB_PADDING="6" # image padding
|
THUMB_PADDING="6" # image padding
|
||||||
DEBUG=$1 # debug output
|
|
||||||
|
# TECHNICAL STUFF
|
||||||
|
DEBUG=0 # debug output
|
||||||
|
THREADS=4
|
||||||
|
|
||||||
# GLOBAL TMP VARIABLES
|
# GLOBAL TMP VARIABLES
|
||||||
G_ROW_WIDTH=0 # combined pic width < WIDTH @ ROW_HEIGHT
|
G_ROW_WIDTH=0 # combined pic width < WIDTH @ ROW_HEIGHT
|
||||||
@ -43,9 +46,9 @@ get_width_by_height() {
|
|||||||
debug "get_width_by_height: FILE=$F TARGET_HEIGHT=$TH FILE_WxH=$WH RET_WIDTH=$R"
|
debug "get_width_by_height: FILE=$F TARGET_HEIGHT=$TH FILE_WxH=$WH RET_WIDTH=$R"
|
||||||
}
|
}
|
||||||
# TOO MANY CONVERT PROCSSES => WAIT
|
# TOO MANY CONVERT PROCSSES => WAIT
|
||||||
bg_check() {
|
thread_check() {
|
||||||
while [ $(pgrep convert | wc -l | awk '{ print $1 }') -gt 4 ];
|
while [ $(pgrep convert | wc -l | awk '{ print $1 }') -gt $THREADS ];
|
||||||
do console "More than 4 convert threads. Waiting..."; sleep 2; done
|
do console "More than $THREADS convert threads. Waiting..."; sleep 2; done
|
||||||
}
|
}
|
||||||
|
|
||||||
# CREATE THUMBNAIL
|
# CREATE THUMBNAIL
|
||||||
@ -54,9 +57,12 @@ create_thumb() {
|
|||||||
local W="$2" # width
|
local W="$2" # width
|
||||||
local H="$3" # height
|
local H="$3" # height
|
||||||
local T="${F%%.*}-$H"
|
local T="${F%%.*}-$H"
|
||||||
if ! [ -f "$THUMB_PATH/$T.gif" ] && ! [ -f "$THUMB_PATH/$T.jpeg" ];
|
if [ -f "$THUMB_PATH/$T.gif" ];
|
||||||
bg_check
|
then printf '%s' "$THUMB_PATH/$T.gif"
|
||||||
then
|
elif [ -f "$THUMB_PATH/$T.jpeg" ];
|
||||||
|
then printf '%s' "$THUMB_PATH/$T.jpeg"
|
||||||
|
else
|
||||||
|
thread_check
|
||||||
case $(printf '%s' "${F##*.}" | tr '[:upper:]' '[:lower:]') in
|
case $(printf '%s' "${F##*.}" | tr '[:upper:]' '[:lower:]') in
|
||||||
gif) console "Creating Thumbnail: $THUMB_PATH/$T.gif"
|
gif) console "Creating Thumbnail: $THUMB_PATH/$T.gif"
|
||||||
nohup convert -quality $THUMB_QUALITY -sharpen 2x2 \
|
nohup convert -quality $THUMB_QUALITY -sharpen 2x2 \
|
||||||
@ -87,7 +93,7 @@ add_image() {
|
|||||||
debug "add_image: max width reached with F=$F @ $G_ROW_WIDTH"
|
debug "add_image: max width reached with F=$F @ $G_ROW_WIDTH"
|
||||||
|
|
||||||
# we're building a row now
|
# we're building a row now
|
||||||
printf "<div class=\"row\">\n";
|
printf " <div class=\"row\">\n";
|
||||||
|
|
||||||
# calculate how much we need to stretch images to fill the
|
# calculate how much we need to stretch images to fill the
|
||||||
# whole row.
|
# whole row.
|
||||||
@ -109,13 +115,13 @@ add_image() {
|
|||||||
console "Adding Image: $RF"
|
console "Adding Image: $RF"
|
||||||
printf ' <div class="image">\n'
|
printf ' <div class="image">\n'
|
||||||
printf ' <a href="'$RF'">\n'
|
printf ' <a href="'$RF'">\n'
|
||||||
printf ' <img width="'$RFW'" height="'$RFH'" src="'$T'">'
|
printf ' <img width="'$RFW'" height="'$RFH'" src="'$T'">\n'
|
||||||
printf ' </a>\n'
|
printf ' </a>\n'
|
||||||
printf ' </div>\n'
|
printf ' </div>\n'
|
||||||
done
|
done
|
||||||
|
|
||||||
# we're done with this row now.
|
# we're done with this row now.
|
||||||
printf "</div>\n";
|
printf " </div>\n";
|
||||||
|
|
||||||
# set leftover file as for next iteration
|
# set leftover file as for next iteration
|
||||||
G_ROW_WIDTH="$NW"
|
G_ROW_WIDTH="$NW"
|
||||||
|
Loading…
Reference in New Issue
Block a user