5

How can I change the dpi value recorded in a JPEG file without actually touching anything else, nor recompressing the image?

Linux compatible solutions are welcome.

This 2011 link says we may not have had a tool to do it back then...

Totor
  • 19,302
  • 17
  • 75
  • 102

1 Answers1

7

You could use exiftool to manipulate EXIF data on different file formats. It's a perl-library accompanied by a command line utility:

$ 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

In this example, EXIF data tells that test.jpg has a resolution of 72×72 dpi. To update this values to e.g. 100×100, exiftool would have to be called like the following:

$ exiftool -XResolution=100 -YResolution=100 test.jpg
1 image files updated

And voilà:

$ 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
Andreas Wiese
  • 10,112
  • 1
  • 32
  • 38
  • 2
    I also had to add `-ResolutionUnit=inches` because JPEGs produced by Simple Scan didn't even have that. – Norrius Jul 13 '19 at 17:11