如何使用 Imagemagick 去除 "date taken" 以外的 EXIF?
How to strip EXIF except "date taken" using Imagemagick?
我想通过剥离 EXIF 元数据 (convert -strip ...
) 来减小图像大小,但问题是我想保留 "date taken" 条目。可能吗?例如:convert -quality 80 -strip-except "date taken" source.jpg dest.jpg
这取决于将 "date taken" "in the correct place" 保存在普通图像查看程序可以解析的位置的重要性。如果你只想要文件somewhere/anywhere中的原始date/time,你可以将其提取并保存在"Comment"字段中,如下所示:
# Use ImageMagick to get the exif:DateTime, e.g. "exif:DateTime: 2014:12:23 13:51:00"
d=$(identify -verbose image.jpg | grep "exif:DateTime:")
# Strip EXIF but then put DateTime in the "Comment" field
convert image.jpg -strip -set comment "$d" result.jpg
更新
实际上,您可以更简洁地获得 date/time,并且以独立于平台的方式使用:
identify -format "%[EXIF:DateTime]" image.jpg
2014:12:23 13:51:00
日期和时间现在位于 "Comment" 字段中,只是 ImageViewers 不会在那里找到它 - 尽管您可以使用:
identify -verbose result.jpg
Image: result.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 3264x2448+0+0
Resolution: 72x72
Print size: 45.3333x34
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
...
...
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 3264x2448+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 96
Orientation: Undefined
Properties:
comment: exif:DateTime: 2014:12:23 13:51:00
不过,更好的方法是使用 jhead
。它有这些选项:
-ft Set filetime to EXIF time
-purejpg Strip EXIF, IPTC and other meta-data
-mkexif Create a minimal EXIF section
-dsft Set EXIF time to filetime
您可以根据需要将它们串在一起,但可能按照我显示的顺序。
我想通过剥离 EXIF 元数据 (convert -strip ...
) 来减小图像大小,但问题是我想保留 "date taken" 条目。可能吗?例如:convert -quality 80 -strip-except "date taken" source.jpg dest.jpg
这取决于将 "date taken" "in the correct place" 保存在普通图像查看程序可以解析的位置的重要性。如果你只想要文件somewhere/anywhere中的原始date/time,你可以将其提取并保存在"Comment"字段中,如下所示:
# Use ImageMagick to get the exif:DateTime, e.g. "exif:DateTime: 2014:12:23 13:51:00"
d=$(identify -verbose image.jpg | grep "exif:DateTime:")
# Strip EXIF but then put DateTime in the "Comment" field
convert image.jpg -strip -set comment "$d" result.jpg
更新
实际上,您可以更简洁地获得 date/time,并且以独立于平台的方式使用:
identify -format "%[EXIF:DateTime]" image.jpg
2014:12:23 13:51:00
日期和时间现在位于 "Comment" 字段中,只是 ImageViewers 不会在那里找到它 - 尽管您可以使用:
identify -verbose result.jpg
Image: result.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 3264x2448+0+0
Resolution: 72x72
Print size: 45.3333x34
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
...
...
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 3264x2448+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 96
Orientation: Undefined
Properties:
comment: exif:DateTime: 2014:12:23 13:51:00
不过,更好的方法是使用 jhead
。它有这些选项:
-ft Set filetime to EXIF time
-purejpg Strip EXIF, IPTC and other meta-data
-mkexif Create a minimal EXIF section
-dsft Set EXIF time to filetime
您可以根据需要将它们串在一起,但可能按照我显示的顺序。