feat: 新增格式转换脚本
分别是给网站项目截图用和相机格式转换(虽然颜色会有问题
This commit is contained in:
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 检查是否提供了目录参数
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: \$0 /path/to/directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 获取目录路径
|
||||
directory="$1"
|
||||
|
||||
# 检查提供的路径是否是一个目录
|
||||
# if [ ! -d "$directory" ]; then
|
||||
# echo "Error: $directory is not a valid directory."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# 切换到指定目录
|
||||
cd "$directory" || exit
|
||||
|
||||
for file in *.HIF; do
|
||||
# 检查文件是否存在
|
||||
if [[ -f "$file" ]]; then
|
||||
# 获取不带扩展名的文件名
|
||||
filename="${file%.*}"
|
||||
jpg_file="${filename}.jpg"
|
||||
|
||||
# 检查对应的 .jpg 文件是否已经存在
|
||||
if [[ -f "$jpg_file" ]]; then
|
||||
echo "Skipping $file, $jpg_file already exists."
|
||||
continue
|
||||
fi
|
||||
|
||||
# 使用 magick 命令转换为 .jpg 格式
|
||||
magick "$file" -colorspace sRGB "$jpg_file"
|
||||
echo "Converted $file to $jpg_file"
|
||||
else
|
||||
echo "No .hif files found in the directory: $directory."
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user