From 084dca081674212d143b88c36b3bafe26b514122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Sun, 10 Nov 2024 01:12:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B4=A2=E5=B0=BC?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E7=94=9F=E6=88=90=E5=9B=BE=E5=BA=93=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E7=9A=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iphone-sony-photo-format.sh | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 iphone-sony-photo-format.sh diff --git a/iphone-sony-photo-format.sh b/iphone-sony-photo-format.sh new file mode 100755 index 0000000..149fb1c --- /dev/null +++ b/iphone-sony-photo-format.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# 这里默认所有的照片都是从索尼相机过来的并且比例是 2:3 + +# 创建文件夹 output +mkdir -p output + +# 遍历当前文件夹下的所有 heic 和 png 文件 +for file in *.{HEIC,heic,PNG,png,JPG,jpg}; do + + # 跳过不存在的文件 + if [[ ! -f "$file" ]]; then + continue + fi + + # 跳过自己改的图片 + if [[ $filename == *"MODIFIED"* ]] || [[ $filename == *"MERGED"* ]]; then + echo "文件名包含 MODIFIED 或 MERGED" + continue + fi + + # 获取图片名并创建新的文件名 + filename=$(basename "$file") + extension="${filename##*.}" + new_extension="jpg" + new_filename="${filename%.*}.$new_extension" + + # 检查输出文件是否已存在 + if [[ -e "output/$new_filename" ]]; then + echo "Skipping existing file: output/$new_filename" + continue + fi + +# if [[ "${filename##*.}" == "png" || "${filename##*.}" == "PNG" ]]; then + # 使用 ImageMagick 直接处理 PNG 图片 +# magick "$file" -gravity center -quality 80 output/$new_filename +# else + # 判断图片是竖屏的还是横屏的 + # 使用 identify 命令判断图片的宽度和高度 + width=$(identify -format "%w" "$file") + height=$(identify -format "%h" "$file") + + # 指定图片大小 + if [ $width -ge $height ]; then + new_size="2250x1500" + else + new_size="1500x2250" + fi + + # 使用 ImageMagick 处理图片 + magick "$file" -gravity center -resize "$new_size^" -extent "$new_size" -quality 80 output/$new_filename +# fi + + # 使用 exiftool 抹掉图片的 gps 信息,并设置作者名称为 Paul + exiftool -overwrite_original -gps:all= -artist="奇趣保罗" -CreatorTool= "output/$new_filename" + + echo "\n\n" + +done