Tsukiji Systems
RSS1.0


googleで
サイト内検索
このブログ
を検索!
  help

巻き戻し中。

2024年
1月
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31


2024-01-05(金) 改良 [長年日記]

_ PC サムネ生成

ImageMagickのconvertを使ってサムネを作成するように改良。

元イメージの大きさにもよるけど、数十倍から100倍ぐらいの読み込み速度になってるはず。

cronで安定運用中。

#!/bin/sh
#################################################
# Auto HTML index generator                     #
# By H.Uekusa 20240105                          #
# Ver 2.00                                      #
#################################################
#################################################
# Location of commands                          #
#################################################
LS="/bin/ls"
PWD="/bin/pwd"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
FIND="/usr/bin/find"
DIFF="/usr/bin/diff"
LOGGER="/usr/bin/logger"
SORT="/usr/bin/sort"
CAT="/bin/cat"
CONV="/usr/local/bin/convert"
#################################################
# Location/Name of files and directories        #
#################################################
PIDFILE="/var/run/make_thumb_index.pid"
PIDFILE2="/var/run/make_thumb_index-oneexec.pid"
BASE_DIR="/HOGEHOGE/HOGEHOGE"
PHOTO_DIR="HOGEHOGEHOGE"
TMP_DIR="/var/tmp"
SELF="/HOGEHOGE/make_thumb_index.sh"
SELF_NAME="make_thumb_index.sh"
HTML_icon="/img/HTML-file.png"
File_icon="/img/simple-file.png"
Folder_icon="/img/simple-folder-b.png"
THUMB_DIR=".thumb"
#################################################
# Parameters for html "table"                   #
#################################################
NUM_FOLD="5"
NUM_FILE="4"
#################################################
# Flags for debug                               #
#################################################
TST_FLAG="0"
LOG_FLAG="0"
#################################################
# Main procedure                                #
#################################################
OPTION=`echo $1`
if [ $TST_FLAG != "0" ];then
        echo $OPTION
fi
#################################################
# Force exec oprion "-f"                        #
#################################################
if [ "$OPTION" == "-f" ];then
        rm -f $TMP_DIR/Photo_LS-LR.prev
        if [ -f "$PIDFILE" ];then
                PIDKILL=`$CAT $PIDFILE`
                $LOGGER -is -t $SELF_NAME "Killing main process $PIDKILL"
                kill -9 $PIDKILL
                rm -f $PIDFILE
        fi
        if [ -f "$PIDFILE2" ];then
                PIDKILL2=`$CAT $PIDFILE2`
                $LOGGER -is -t $SELF_NAME "Killing child process $PIDKILL2"
                kill -9 $PIDKILL2
                rm -f $PIDFILE2
        fi
        $SELF
        exit 4
#################################################
# Normal execute mode                           #
#################################################
elif [ "$OPTION" == "" ];then
        if [ -f "$PIDFILE" ];then #Exist PID file?
                $LOGGER -is -t $SELF_NAME "There is PID file at $PIDFILE,I am exiting"
                $LOGGER -is -t $SELF_NAME "If you would like to start forcibly, Use -f option first"
                exit 2
        fi
        PID=`echo $$`
        echo $PID > $PIDFILE
        $FIND $BASE_DIR/$PHOTO_DIR -ls \
                |$GREP -v $THUMB_DIR \
                |$AWK 'NR > 0 \
                {printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
                for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\""  }' \
                | $GREP $PHOTO_DIR \
                > $TMP_DIR/Photo_LS-LR
        if [ ! -f $TMP_DIR/Photo_LS-LR.prev ];then
                touch $TMP_DIR/Photo_LS-LR.prev
        fi
        $DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev \
                >/dev/null 2>&1
        DIFF_STAT=`echo $?`
        if [ $TST_FLAG != "0" ];then
                echo "diff-stat $DIFF_STAT"
        fi
        if [ "$DIFF_STAT" == "1" ];then
                $DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP "^< d" \
                        |$GREP -v $THUMB_DIR \
                        |$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/"  }' \
                        | sed s/'"\/$'/'\/"'/g \
                        > $TMP_DIR/Photo-DIR.0
                $DIFF $TMP_DIR/Photo_LS-LR $TMP_DIR/Photo_LS-LR.prev | $GREP -v "^< d" \
                        |$GREP -v $THUMB_DIR \
                        |$AWK 'NR > 0 {for ( i = 7 ; i < NF ; i++ ) { printf ( "%s ", $i ) } printf $NF ; print "/"  }' \
                        | sed s/'"\/$'/'\/"'/g \
                        | $AWK -F/ '{for (i = 1; i <= NF - 2 ; i++){printf $i"/"};print "\"" }' \
                        >> $TMP_DIR/Photo-DIR.0
                $SORT -u $TMP_DIR/Photo-DIR.0 | $GREP -v '^\"$' > $TMP_DIR/Photo-DIR
                DIFF_COUNT=`$CAT $TMP_DIR/Photo-DIR | wc -l | $AWK '{print $1}'`
                if [ "$LOG_FLAG" == "0" ];then
                        $LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is $DIFF_COUNT diff"
                        $LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking index..."
                else
                        echo "There is $DIFF_COUNT diff"
                fi
                $AWK -v SELF=$SELF '{system ("cd "$0"; "SELF" -oneexec"); \
                        printf("%100s\r"," "); \
                        printf $0"\r"}; END {printf "\n"}' $TMP_DIR/Photo-DIR
                $FIND $BASE_DIR/$PHOTO_DIR -ls |$AWK 'NR > 0 \
                        {printf $3" "$7" "$8" "$9" "$10" "; printf "\"" ; \
                        for (i = 11; i < NF; i++) { printf("%s ", $i) } printf $NF; print "\""  }' \
                        |$GREP $PHOTO_DIR \
                        |$GREP -v $THUMB_DIR \
                        > $TMP_DIR/Photo_LS-LR.prev
                $LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "Remaking $DIFF_COUNT indexes done"
                rm -f $PIDFILE
                exit 1
        else
                if [ "$LOG_FLAG" == "0" ];then
#                       $LOGGER -is -t $SELF_NAME "make_thumb_index.sh" "There is no diff"
                else
                        echo "There is no diff"
                fi
        fi
                rm -f $PIDFILE
                exit 0
#################################################
# One exec mode for each directories            #
# (For child process)                           #
#################################################
elif [ "$OPTION" == "-oneexec" ];then
        PID2=`echo $$`
        echo $PID2 > $PIDFILE2
        if [ $TST_FLAG == "0" ];then
                echo "<html>" > index.html
                echo "<head></head>" >> index.html
                echo "<body>" >> index.html
                $PWD | $AWK -F$BASE_DIR/ '{print "<font size=+3><b>Index of /"$2"</b></font><br>"}' \
                        >> index.html
                echo "<font size=+2><b><a href='"'../'"' > Parent Directory </a></b></font><br><br><b>" \
                        >> index.html
                echo -n `$LS -lp | $GREP -v ^d | $GREP -v ^total |wc -l` \
                        >> index.html
                echo -n " Files  " >> index.html
                echo -n `$LS -lp | $GREP ^d | $GREP -v ^total |wc -l` \
                        >> index.html
                echo " Directories</b><br>" >> index.html
                echo "<table border=1><tr>" >> index.html
                $LS -lp | $GREP ^d \
                        | $GREP -v $THUMB_DIR \
                        | $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
                        | $AWK '{print $0}' | sort \
                        | $AWK -F. -v Folder_icon=$Folder_icon -v NUM_FOLD=$NUM_FOLD '{\
                        if ($0 ~ /\/ $/) \
                         {print "<td><a href=\"./"$0"\"><img width=120 src=\""Folder_icon"\"><br>"$0"</a></td>"} \
                        if (NR % NUM_FOLD == 0) {print "</tr><tr>"} }\
                        END{if (NR % NUM_FOLD != 0) {print "</tr>"} \
                         }' >> index.html
                if [ ! -d "./$THUMB_DIR" ];then
                        mkdir "./$THUMB_DIR"
                fi
                $LS -lp | $GREP -v ^d | $GREP -v ^total \
                        | $AWK '{c="";for(i=9;i<=NF;i++) c=c $i" "; print c}' \
                        | $AWK '{print $0}' | sort \
                        | $AWK -F. -v HTML_icon=$HTML_icon -v File_icon=$File_icon \
                          -v NUM_FILE=$NUM_FILE -v THUMB_DIR=$THUMB_DIR -v CONV=$CONV '{\
                        if ($2 == "JPG " || $2 == "jpg " || $2 == "jpeg " || $2 == "gif " || $2 == "BMP " || $2 == "bmp " || $2 == "png ") \
                         {system (CONV" -auto-orient -resize 240x ./"$0" ./"THUMB_DIR"/"$0); \
                          print "<td><a target=\"_blank\" href=\"./"$0"\"><img width=240 src=\"./"THUMB_DIR"/"$0"\"><br>"$0"</a></td>"}\
                        else if($2 == "html " || $2 == "HTML " || $2 == "htm " ||$2 == "HTM ") \
                         {print "<td><a href=\"./"$0"\"><img width=80 src=\""HTML_icon"\"><br>"$0"</a></td>"} \
                        else {print "<td><a href=\"./"$0"\"><img width=80 src=\""File_icon"\"><br>"$0"</a></td>"} \
                        if (NR % NUM_FILE == 0) {print "</tr><tr>"} }\
                        END{print "</tr>" }' \
                        >> index.html
        echo "</table>" >> index.html
        echo "</body>" >> index.html
        echo "</html>" >> index.html
        fi
        rm -f $PIDFILE2
        exit 3
fi
#################################################
# Error handling for unknown option             #
#################################################
echo "Unknown option"
echo "Usage: \"make_thumb_index.sh\" for all recurcive directories from BASE_DIR"
echo "       or \"make_thumb_index.sh -oneexec\" for current directory"
echo "       or \"make_thumb_index.sh -f\" for execute forcibly"
exit 9
*1

*1 バージョンは2.0になっておりますw

_

机上のデジタルマルチメータとAR8600を置いているメタルラックの下、少し隙間があって書類とか物を置きたい。

100均で丁度よい横幅の金網があったので、3Dプリンタで脚を作成。

ぴったりの高さで作れるので、きちんと収まってよろしい(・∀・)

それにしても、4本出すと24時間越えるのしんどいな。

スライス出力

3D作図

じんわり出力



過去の写真!
良い感じに付いた(・∀・) 削るぜ! オリジナル(すり減ってる) バンジョーはあるんだがw
アクセスカウンター!
累計:
本日:
昨日:
最近のツッコミ

(´・ω・`)ショボーン