代码拉取完成,页面将自动刷新
#!/bin/bash
#===============================================
# generate thumbnail images for tagspaces
#===============================================
generate_thumbnails() {
dirname="$1"
thumbdir="$dirname/.ts"
echo "Current dir: $dirname"
mkdir -p "$thumbdir"
#for file in "$dirname/"*
find "$dirname" -type f -maxdepth 1 | while read file
do
# next line checks the mime-type of the file
CHECKTYPE=`file --mime-type -b "$file" | awk -F'/' '{print $1}'`
if [ "x$CHECKTYPE" == "ximage" ];
then
thumbfile="$thumbdir/$(basename "$file").jpg"
CHECKWIDTH=`identify -format "%W" "$file"` # this returns the image width
#CHECKSIZE=`stat -f "%z" "$file"` # MAC this returns the filesize
CHECKSIZE=`stat -c %s "$file"` # LINUX this returns the filesize
#FILEDATE=`stat -f "%c" "$file"` # MAC this returns the file timestamp
FILEDATE=`stat -c %Z "$file"` # LINUX this returns the file timestamp
#echo "File - $file - Date: $FILEDATE - Size: $CHECKSIZE"
if [ -f "$thumbfile" ]; then
#THUMBFILEDATE=`stat -f "%c" "$thumbfile"` # MAC
THUMBFILEDATE=`stat -c "%Z" "$thumbfile"`
if [ $THUMBFILEDATE -gt $FILEDATE ]; then
echo "$file is not changed"
continue
fi
fi
# next 'if' is true if either filesize >= 200000 bytes OR if image width >=201
if [ $CHECKSIZE -ge 200000 ] || [ $CHECKWIDTH -ge 201 ]; then
echo "$file -> $thumbfile"
convert -thumbnail 400 "$file" "$thumbfile"
fi
fi
done
}
if [ $# -ne 1 ]; then
echo "Usage $0 <path>"
exit 2
fi
find $1 -type d -not -path "*.ts" | while read dir
do
generate_thumbnails "$dir"
done
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。