在 Linux 上无损地更改 JPEG 的 dpi 值

Tot*_*tor 4 linux jpeg dpi

如何更改dpi记录在 JPEG 文件中的值而不实际触及任何其他内容,也不重新压缩图像?

欢迎使用 Linux 兼容的解决方案。

这个 2011 年的链接说我们当时可能没有工具来做到这一点......

And*_*ese 5

您可以使用exiftool不同的文件格式来操作 EXIF 数据。它是一个带有命令行实用程序的 perl 库:

$ exiftool test.jpg | grep -i resolution
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Focal Plane X Resolution        : 3959.322034
Focal Plane Y Resolution        : 3959.322034
Focal Plane Resolution Unit     : inches
Run Code Online (Sandbox Code Playgroud)

在此示例中,EXIF 数据表明test.jpg其分辨率为 72×72 dpi。要将这个值更新为例如 100×100,exiftool必须像下面这样调用:

$ exiftool -XResolution=100 -YResolution=100 test.jpg
1 image files updated
Run Code Online (Sandbox Code Playgroud)

瞧:

$ exiftool test.jpg | grep -i resolution
X Resolution                    : 100
Y Resolution                    : 100
Resolution Unit                 : inches
Focal Plane X Resolution        : 3959.322034
Focal Plane Y Resolution        : 3959.322034
Focal Plane Resolution Unit     : inches
Run Code Online (Sandbox Code Playgroud)

  • 我还必须添加“-ResolutionUnit=英寸”,因为 Simple Scan 生成的 JPEG 甚至没有这个。 (2认同)