Ai
1 Star 0 Fork 0

懒懒的狸花猫/tagspaces

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
thumbgen.sh 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
Ilian Sapundshiev 提交于 2018-11-12 21:43 +08:00 . added tmb generation script
#!/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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dxpAndroid/tagspaces.git
git@gitee.com:dxpAndroid/tagspaces.git
dxpAndroid
tagspaces
tagspaces
develop

搜索帮助