From 6a0fb5875e4cadfe333f8ddd3a110c687b5948c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Mon, 13 Oct 2025 02:34:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=BF=98=E5=8E=9F=20E?= =?UTF-8?q?XIF=20=E8=84=9A=E6=9C=AC=EF=BC=8C=E8=BD=AC=E6=8D=A2=20PNG=20?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recover-modified-photo-exif.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/recover-modified-photo-exif.sh b/recover-modified-photo-exif.sh index 0d4972e..3ffc3e5 100755 --- a/recover-modified-photo-exif.sh +++ b/recover-modified-photo-exif.sh @@ -1,6 +1,7 @@ #!/bin/bash # 这个脚本用于还原 EXIF 数据,传递原始 EXIF 图片的路径(第一个参数),还原修改过 EXIF 的图片的路径(第二个参数) +# Example: ./recover-modified-photo-exif.sh /Volumes/未命名导出 . # 检查参数 if [ "$#" -ne 2 ]; then @@ -18,6 +19,35 @@ if [ ! -d "$SUCCEED_DIR" ]; then echo "创建 succeed 目录: $SUCCEED_DIR" fi +# 处理被修改的文件夹中的所有 PNG 文件 +for png_file in "$TARGET_DIR"/*.png; do + # 跳过 succeed 目录中的文件 + if [[ "$png_file" == *"/succeed/"* ]]; then + continue + fi + + # 检查文件是否存在(防止没有 png 文件时报错) + if [ ! -f "$png_file" ]; then + continue + fi + + # 获取文件名(不包括路径和扩展名) + filename=$(basename "$png_file") + base_filename="${filename%.png}" + jpg_file="$TARGET_DIR/$base_filename.jpg" + succeed_jpg_file="$SUCCEED_DIR/$base_filename.jpg" + + # 如果当前目录或 succeed 目录下同名 JPG 文件已存在,则跳过 + if [ -f "$jpg_file" ] || [ -f "$succeed_jpg_file" ]; then + echo "$jpg_file 或 $succeed_jpg_file 已存在,跳过 PNG 转换" + continue + fi + + # 使用 ImageMagick 的 convert 命令将 PNG 转换为 JPG,设置质量为100(无压缩) + convert "$png_file" -quality 100 "$jpg_file" + echo "$filename 已转换为 JPG: $jpg_file" +done + # 遍历被修改的文件夹中的所有 JPG 文件 for target_file in "$TARGET_DIR"/*.jpg; do # 跳过 succeed 目录中的文件