用 PowerShell 提取照片的 EXIF 元数据

System.Drawing 把每条 EXIF 标签暴露为 PropertyItem——直接从 JPEG 里读取拍摄时间、相机型号或 GPS 数据。

WindowsEXIF 信息媒体PowerShell低风险
用 System.Drawing 加载图片后枚举 `$img.PropertyItems`,再按标签 ID 解码 Value 字节。

01命令

命令
$ Add-Type -AssemblyName System.Drawing; $img=[System.Drawing.Image]::FromFile('C:\Pictures\photo.jpg'); $img.PropertyItems | Select-Object Id, Type, Len | Format-Table; $img.Dispose()

02作用说明

每个 PropertyItem 包含 Id(EXIF 标签号——0x9003 是拍摄时间,0x0110 是相机型号)、Type、Len 和原始的 Value 字节数组,需按类型(ASCII 字符串、short、有理数)解码。这比专用 EXIF 库麻烦一些,但什么都不用安装。PropertyItems 集合也可以写入,所以脚本同样能在分享照片前清除或改写标签——一个轻量的隐私清理方案。

03风险

风险低风险
使用条件PropertyItem values are raw bytes; interpret well-known IDs (e.g. 0x0132 DateTime) or via the System.Drawing.Imaging.PropertyItem docs.

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • PropertyItem Class | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    依据: Microsoft documents System.Drawing.Imaging.PropertyItem with Id, Len, Type, and Value properties that hold image metadata (EXIF) items.
  • Image Class (System.Drawing) | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    依据: Microsoft documents the Image.PropertyItems collection that exposes the metadata items stored in a loaded image.

最后验证: 2026-09-17 · 分类: 媒体

06相关方案