Files
SnapOtter/apps/docs/zh-CN/tools/image/edit-metadata.md
T
SnapOtterandGitHub f858c4cea0 feat: clearer, disambiguated tool names across all surfaces (#520)
Renames 18 ambiguous or hard-to-search tool names so image tools self-qualify like the other modalities ("Compress" becomes "Compress Image"), and cleans up a few awkward names. Propagated across search (constants.ts), display (en.ts + 20 locales), the OpenAPI base spec + 20 locale specs, and the docs tool-page headings in 21 languages. Removes the duplicate "Normalize Audio" summary shared by the video and audio endpoints. Tool ids and routes are unchanged, so no API paths or bookmarks break.
2026-07-15 21:55:51 +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 元数据字段,无需重新编码像素。 9271d3d8f278 human 7b3853980f3b

编辑图片元数据

编辑图片的元数据字段,包括 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 对象名称
iptcHeadline string - IPTC 标题
iptcCity string - IPTC 城市
iptcState string - IPTC 省/州
iptcCountry string - IPTC 国家

请求示例

设置作者和版权:

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 预览。