Last active
April 5, 2020 15:55
-
-
Save maboloshi/ec109bc3fc31e0b7f3c87b21fd142f8d to your computer and use it in GitHub Desktop.
图片转换并缩小 #convert #imagemagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# 在需要转换图片的目录下运行此脚本 | |
# convert命令是ImageMagick这个图片处理软件包中的一个命令 | |
# 安装ImageMagick之后,才能使用convert命令 | |
# man convert可以查看命令用法帮助文档 | |
# 逐个将所有png,bmp,jpg格式图片文件转换为原来尺寸的1/4大并保存为jpg格式图片文件 | |
# 转换后重命名 | |
# 然后,删除原文件 | |
for image in $(find *.{png,bmp,jpg,jpeg,PNG,BMP,JPG,JEPG} ! -name '*_converted*' 2>/dev/null) ; do | |
convert -resize 25% "$image" "${image%%.*}_converted.jpg" | |
# 不加_converted,jpg文件会重复转换 | |
echo "$image -> ${image%%.*}_converted.jpg" | |
# rm "$image" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment