Created
June 18, 2026 08:45
-
-
Save Mirochiu/c6b92ba93817e53a140d164bdf07d1d0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| shopt -s nullglob | |
| CSV="photos.csv" | |
| echo "Name,Latitude,Longitude,Image" > "$CSV" | |
| for file in *.jpg *.JPG *.jpeg *.JPEG; do | |
| [[ -f "$file" ]] || continue | |
| base="${file%.*}" | |
| out="${base}_sm.jpg" | |
| echo "Processing $file" | |
| # 1. 縮圖(寬 1024,不放大小圖) | |
| convert "$file" -resize '1024x>' "$out" | |
| # 2. 複製完整 EXIF | |
| exiftool -overwrite_original \ | |
| -tagsFromFile "$file" \ | |
| -all:all \ | |
| "$out" >/dev/null | |
| # 3. 取得 GPS | |
| lat=$(exiftool -n -GPSLatitude -s3 "$file") | |
| lon=$(exiftool -n -GPSLongitude -s3 "$file") | |
| if [[ -n "$lat" && -n "$lon" ]]; then | |
| echo "${base},${lat},${lon},${out}" >> "$CSV" | |
| echo " GPS: $lat, $lon" | |
| else | |
| echo " No GPS found" | |
| fi | |
| done | |
| echo | |
| echo "Done!" | |
| echo "Generated:" | |
| echo " - *_sm.jpg" | |
| echo " - $CSV" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment