parent
084dca0816
commit
2f743f0915
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 检查是否安装了必要的工具
|
||||||
|
if ! command -v magick &> /dev/null; then
|
||||||
|
echo "错误: 未找到 ImageMagick,请先安装 ImageMagick"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v exiftool &> /dev/null; then
|
||||||
|
echo "错误: 未找到 ExifTool,请先安装 ExifTool"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 遍历当前目录下的所有 PNG 文件
|
||||||
|
for png_file in *.png; do
|
||||||
|
# 检查文件是否存在(防止没有 png 文件时的错误)
|
||||||
|
if [ ! -f "$png_file" ]; then
|
||||||
|
echo "当前目录下没有 PNG 文件"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 获取文件名(不含扩展名)
|
||||||
|
filename="${png_file%.*}"
|
||||||
|
|
||||||
|
# 转换为 WebP 格式
|
||||||
|
echo "正在转换: $png_file -> ${filename}.webp"
|
||||||
|
magick "$png_file" "${filename}.webp"
|
||||||
|
|
||||||
|
# 写入作者信息
|
||||||
|
echo "正在写入作者信息到: ${filename}.webp"
|
||||||
|
exiftool -overwrite_original -Author="奇趣保罗" "${filename}.webp"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "所有文件处理完成!"
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
mkdir -p output
|
mkdir -p output
|
||||||
|
|
||||||
# 遍历当前文件夹下的所有 heic 和 png 文件
|
# 遍历当前文件夹下的所有 heic 和 png 文件
|
||||||
for file in *.{HEIC,heic,PNG,png,JPG,jpg}; do
|
for file in *.{HEIC,heic,HEIF,heif,PNG,png,JPG,jpg}; do
|
||||||
|
|
||||||
# 跳过不存在的文件
|
# 跳过不存在的文件
|
||||||
if [[ ! -f "$file" ]]; then
|
if [[ ! -f "$file" ]]; then
|
||||||
|
|
@ -54,6 +54,6 @@ for file in *.{HEIC,heic,PNG,png,JPG,jpg}; do
|
||||||
# 使用 exiftool 抹掉图片的 gps 信息,并设置作者名称为 Paul
|
# 使用 exiftool 抹掉图片的 gps 信息,并设置作者名称为 Paul
|
||||||
exiftool -overwrite_original -gps:all= -artist="奇趣保罗" -CreatorTool= "output/$new_filename"
|
exiftool -overwrite_original -gps:all= -artist="奇趣保罗" -CreatorTool= "output/$new_filename"
|
||||||
|
|
||||||
echo "\n\n"
|
echo '\n\n'
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue