[Solved] How to change resolution metadata of a lossy image format like JPEG without recompression?

Having tech problems? Post them here and do not worry, there is always a solution for you.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

[Solved] How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by porg »

image.jpg falsely has 72 DPI instead of 600 DPI at which it was scanned.

Solution for JPEGs in GraphicConverter

❌ Don't do this:
1) Open image in GraphicConverter
2) Menu → Picture → Resolution…
3) "Scale Picture" is OFF (=no pixel interpolations, just a metadata operation) + Change Unified PPI to your desired PPI.
4) But then when you save the picture with ⌘-S it recompresses the image. We won't to avoid that.


✅ Hence do this:
1) Open image parent folder in GraphicConverter and select the image.
2) Menu → General → JPEGs → Change Resolution Value lossless…
3) Change Resolution Losslessly to: Desired PPI.
4) Click OK.
5) All fine: The resolution metadata gets updated. The modification date gets updated. The file is overwritten! So make a backup before in case you are worried. Note: Changing back the resolution value without a backup is easy too: Just run again with the resolution value it had before.

❗️ Note "Losslessly" is not a correct adverb in English AFAIK. "Lossless" is already an adverb.


Solution for JPEGs in ExifTool

Code: Select all

exiftool /path/to/image.jpg -xresolution=600 -yresolution=600 -v2
• Change the numeric resolution values as desired.
• The -v2 argument is not necessary. Just gives you verbose info what exactly was updated (or not in case of failure).
• No need for a file backup. ExifTool creates a backup with an "_original" suffix (e.g. "image.jpg_original") and only then overwrites.

Processed file outcomes GraphicConverter vs. ExifTool
• Sometimes the same outcome.
• Sometimes slightly different outcome (e.g. 88 bytes difference).
• 3 permutations possible: Source contains no EXIF + Source contains EXIF and you choose Modify only values in JPEG APP0 Marker vs. Modify JPEG APP0 Marker and Exif if available. I guess that explains the sometimes slightly different outcome.
• Does GraphicConverter use ExifTool for that operation? Or its own methods?


Is there also a lossless Resolution metadata change for other lossless file formats, e.g. webp ?

• If a WEBP is selected you can still open: Menu → General → JPEGs → Change Resolution Value lossless…
• And run the dialog. No error is thrown. But the file remains untouched.
User avatar
PakkyT
Posts: 76
Joined: Sun Jul 21, 2019 8:59 pm
Location: Massachusetts USA
Country: United States
Contact:

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by PakkyT »

The resolution metadata is just a tag in the exif. It has nothing to do with the saved image and you should be able to change it to any value you want without doing anything to the photo data in the file. It is kind of a pointless metadata field.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by forum_adm »

The change of the resolution with the command in the browser does only change the metadata and does not recompress.

The resolution can be stored in JPEGs in XMP, Exif and the JFIF header.

The change of the modification date is correct: because the file get modified. The XMP, Exif and JFIF Header has to be rewritten/updated.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by forum_adm »

P.S. The function is very old and supports currently only JPEGs.
I will modify it the next days. So, it will support all image formats.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by porg »

👍 cool that you want to support lossless resolution overriding for all/most lossy image formats!

Do you plan to write this as custom code? Or use a library /helper-app for that like ExifTool?
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by forum_adm »

I added it to build 6122 and moved the item.
Screenshot 2023-05-17 at 08.50.23.jpg
Screenshot 2023-05-17 at 08.50.23.jpg (252.11 KiB) Viewed 3162 times
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by porg »

Tested in b6122: ✅ Works for JPEG, PNG. ❌ But fails for WEBP.

GraphicConverter 12 b6122 Change resolution lossless fails for WEBP.png
GraphicConverter 12 b6122 Change resolution lossless fails for WEBP.png (170.85 KiB) Viewed 3158 times
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by forum_adm »

The ExifTool command does only change existing fields. It does not add Exif tags.

I will add an option to force the adding.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by porg »

👍 I agree: In case of a user running "Change Resolution lossless…" and setting it to a concrete value the enforced creation of metadata header appropriate to the image format (e.g.EXIF) in order to store the Resolution value within, is without doubt the correct behavior!

❗️ Related and important: In case of "Safe for Web…" setting a metadata header (EXIF or IPTC) is an explicit user choice, whereas setting a resolution tag within that header for preservation purposes is an implicit action depending on the explicit one. Hence for "Safe for Web…" I proposed a differentiated behavior.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: How to change resolution metadata of a lossy image format like JPEG without recompression?

Post by porg »

In b6123 I selected my test set of 6 files again, then applied "Change Resolution lossless…" on all at once, and the WEBPs did not change.

I guess this is yet not implemented.
Post Reply