登录后台

页面导航

#无损压缩目录及子目录下的jpg图片:
find /www/wwwroot/pic_com/d/file/selfies/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.jfif" \) -exec jpegoptim --strip-all {} \;

#优化版:
find /www/wwwroot/pic_com/d/file/selfies/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.jfif" \) -print0 | xargs -0 jpegoptim --strip-all --all-progressive --max=100 --preserve --totals
#2核心
find /www/wwwroot/pic_com/d/file/selfies/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.jfif" \) -print0 | parallel -0 -j 2 'jpegoptim --strip-all --all-progressive --max=100 --preserve --nooverwrite "{}" 2>/dev/null || true'



#无损压缩目录及子目录下的png图片:
find /www/wwwroot/pic_com/d/file/selfies/ -type f -iname "*.png" -exec optipng -o7 {} \;

#2核心优化版
find /www/wwwroot/pic_com/d/file/selfies/ -type f -iname "*.png" -print0 | parallel -0 -j 2 'optipng -o7 -preserve "{}" || echo "❌ 压缩失败: {}"'


#图片压缩转换为 .webp
#原地覆盖版本
find /www/wwwroot/pic_com/d/file/selfies/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | while read -r file; do
    cwebp -q 75 "$file" -o "${file%.*}.webp" && rm "$file"
done
#-q 70    轻度压缩,体积小 60–80% 缩略图、移动端
#-q 80    均衡(推荐) 普通网站图片
#-q 90    保真度高 高清图、封面图

#使用 nice 降低进程优先级
find /www/wwwroot/pic_com/d/file/selfies/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | while read -r file; do
    nice -n 10 cwebp -q 75 "$file" -o "${file%.*}.webp" && rm "$file"
done