5

Sometimes I have image files which I want to contain a certain DPI setting. Note that I mean just the DPI value, i.e. just the value in the image's metadata. I don't want to resize the actual image. So for example a higher DPI would result in a smaller size in centimeters, and the same amount of pixels.

I know I can set or change an image's DPI using ImageMagick convert with the -density parameter, but this will re-encode the image. I want to avoid that.

Is there a way, with ImageMagick or something else (e.g. ExifTool or something) to explicitly set a JPEG's DPI value without changing the actual compressed image contents itself?

Note that I'm using OS X and looking for a command line tool to do this (I want to use it in shell scripts).

RocketNuts
  • 1,342

1 Answers1

13

You can do this with exiftool.

You command would be:

exiftool -XResolution=# -YResolution=# FileOrDir

Change the hashmark to the new DPI number. This command will make backups of each file, which you can avoid by adding the -overwrite_original option. Related is -ResolutionUnit which can be set to None, inches, or cm.

Also note that resolution tags may appear in multiple groups in the file, and some of them may require them to be specifically changed. Use the command in Exiftool FAQ #3 to make sure that you have changed them all.

Giacomo1968
  • 58,727
StarGeek
  • 1,644