Files
SnapOtter/apps/docs/zh-TW/tools/image/edit-metadata.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

4.2 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
編輯圖片中的 EXIF、IPTC、GPS 與 XMP 中繼資料欄位,無需重新編碼像素。 a37746db11c3 human bac2c78cbec4

編輯中繼資料

編輯圖片中繼資料欄位,包含 EXIF、IPTC、GPS 座標、日期與關鍵字。底層使用 ExifTool,因此中繼資料會就地寫入而不重新編碼像素,完整保留圖片品質。

API 端點

編輯中繼資料

POST /api/v1/tools/image/edit-metadata

將中繼資料欄位寫入圖片並回傳修改後的檔案。

檢視中繼資料

POST /api/v1/tools/image/edit-metadata/inspect

透過 ExifTool 以 JSON 回傳圖片的完整中繼資料。不會修改圖片。

參數(編輯)

參數 類型 必填 預設值 說明
title string - 圖片標題(XMP/EXIF
author string - 作者名稱
artist string - 藝術家名稱(EXIF Artist 標籤)
copyright string - 版權聲明
imageDescription string - 圖片描述(EXIF
software string - 軟體標籤
dateTime string - EXIF DateTime 值
dateTimeOriginal string - EXIF DateTimeOriginal 值
setAllDates string - 一次設定所有日期欄位
dateShift string - 依偏移量位移所有日期(格式:+HH:MM-HH:MM
clearGps boolean false 移除所有 GPS 資料
gpsLatitude number - 設定 GPS 緯度(-90 至 90
gpsLongitude number - 設定 GPS 經度(-180 至 180
gpsAltitude number - 設定 GPS 海拔(公尺)
keywords string[] - 要新增或設定的關鍵字/標籤
keywordsMode string "add" 關鍵字的處理方式:add(附加)或 set(取代)
fieldsToRemove string[] [] 要移除的特定中繼資料欄位名稱清單
iptcTitle string - IPTC Object Name
iptcHeadline string - IPTC Headline
iptcCity string - IPTC City
iptcState string - IPTC Province/State
iptcCountry string - IPTC Country

範例請求

設定作者與版權:

curl -X POST http://localhost:1349/api/v1/tools/image/edit-metadata \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo.jpg" \
  -F 'settings={"author": "Jane Smith", "copyright": "2024 Jane Smith"}'

設定 GPS 座標:

curl -X POST http://localhost:1349/api/v1/tools/image/edit-metadata \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo.jpg" \
  -F 'settings={"gpsLatitude": 48.8566, "gpsLongitude": 2.3522, "gpsAltitude": 35}'

移除 GPS 並新增關鍵字:

curl -X POST http://localhost:1349/api/v1/tools/image/edit-metadata \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo.jpg" \
  -F 'settings={"clearGps": true, "keywords": ["landscape", "sunset"], "keywordsMode": "add"}'

檢視中繼資料:

curl -X POST http://localhost:1349/api/v1/tools/image/edit-metadata/inspect \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo.jpg"

範例回應(編輯)

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/photo.jpg",
  "originalSize": 2450000,
  "processedSize": 2452000
}

備註

  • 此工具需要伺服器上安裝 ExifTool。它已包含在 Docker 映像中。
  • 中繼資料會就地寫入,因此不會發生像素重新編碼。檔案大小的變動極小(僅為中繼資料的位元組)。
  • dateShift 參數會依指定偏移量位移所有日期欄位,適用於修正時區錯誤(例如 +02:00-05:30)。
  • 若未請求任何變更(所有參數皆省略或為空),則原檔會原樣回傳。
  • 支援的格式:JPEG、PNG、WebP、AVIF、TIFF、GIF、HEIC/HEIF。
  • 對於瀏覽器無法預覽的格式(HEIF、TIFF),回應會包含一個 previewUrl 欄位,內含 WebP 預覽。