[Closed] Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Want to submit a new feature, an enhancement ? Do it here !
Post Reply
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

[Closed] Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Post by porg »

User Goal: When saving a file for the web (lossy or lossless) there are some possibilities to through away as much as possible (EXIF metadata, embedded thumbnails, etc) to which is not crucially necessary for display/rendering. Also the color profile information, if the image is already using the default color profile assumed (=sRGB).

Nevertheless I'd like to keep the DPI information as an explicit distinguisher this is a normal resolution file (72DPI aka @1x) this is a @2x (144 DPI) and so forth.


For JPEG the situation is satisfactory

Even when having "Postprocess by ImageOptim" enabled which carries the warning "Might strip away some metadata" the DPI info is still kept. Only if one also disables "Write JFIF header" then the DPI information is lost. So that JFIF header which is quite small is enough to maintain the DPI information.


For WEBP the situation is as follows

[√] Store Metadata: [√] ICC [√] XMP [√] EXIF

DPI information makes it into the WEBP if XMP is enabled.
File with XMP has 2804 bytes more than with no metadata at all.
Is there a somehow more space efficient possibility to get "DPI information" into a WEBP than that?
Last edited by porg on Sat Oct 29, 2022 5:09 pm, edited 1 time in total.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: Possibility for WEBP to keep DPI metadata info when saving lossless + size optimized ?

Post by forum_adm »

JPEG stores the resolution in the standard JFIF header and in addition into Exif.

WebP stores it only in Exif.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: Possibility for WEBP to keep DPI metadata info when saving lossless + size optimized ?

Post by porg »

Why did my export experiments then show that DPI info survived only depending whether XMP was enabled, while the EXIF checkmark did not matter?

My experience contradicts your statement.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: Possibility for WEBP to keep DPI metadata info when saving lossless + size optimized ?

Post by forum_adm »

Exif is mirrored to the XMP Exif tags, too.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Post by porg »

When selecting WEBP as the file output format you have options which metadata to include into the file: None, EXIF, ICC, XMP.

My screenshot below shows my attempts of embedding PPI resolution metadata into a WEBP file with GraphicConverter (GC) and its different methods Quick Convert (QC) • Save for Web (S4W) • Save a Copy as (SC).

- On top the PNG (@2x 144dpi) exported from a .snagx (Snagit capture file)
- Quick Convert (QC): Only when XMP is included the PPI info makes it into the WEBP file.
- Save for Web (S4W): None of the methods write a DPI info into the WEBP file!
- Save a Copy as (SC): Only when XMP is included the PPI info makes it into the WEBP file.
- On the bottom there is "… SNAGIT.webp" @2x export created with SnagIt, which also fails to include the PPI info.

PPI in WEBP.png
PPI in WEBP.png (176.97 KiB) Viewed 901 times
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Post by porg »

The source file is a .snagx file which was captured on my Retina Screen @2x.
From Snagit I exported a @2x PNG.
This PNG shows as 144 PPI in GraphicConverter and was the source for all my "GC" file export variants.

As this is not a digital camera file, but a PNG export from a graphic app, it seems to have no EXIF, but some minimal metadata in its header.
In the Browser Preview Panel the "Exif" tab is empty. The "Exif tool" tab shows this:

Code: Select all

---- ExifTool ----
ExifTool Version Number: 12.49
---- System ----
… Various Filesystem Infos …
---- File ----
File Type: PNG
File Type Extension: png
MIME Type: image/png
Exif Byte Order: Big-endian (Motorola, MM)
---- PNG ----
Image Width: 2362
Image Height: 4320
Bit Depth: 8
Color Type: RGB
Compression: Deflate/Inflate
Filter: Adaptive
Interlace: Noninterlaced
SRGB Rendering: Perceptual
---- PNG-pHYs ----
Pixels Per Unit X: 5669
Pixels Per Unit Y: 5669
Pixel Units: meters
---- IFD0 ----
X Resolution: 144
Y Resolution: 144
Resolution Unit: inches
---- ExifIFD ----
Color Space: sRGB
Exif Image Width: 2362
Exif Image Height: 4320
---- Composite ----
Image Size: 2362x4320
Megapixels: 10.2
Both IFD0 and PNG-pHYs seem to contain some density information: IFD0 screen resolution + PNG-pHYs print resolution.
How can this resolution info make it into the adequate WEBP counterpart?
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Post by forum_adm »

The webP format does not store the resolution.

This is only supported by storing an Exif or XMP record.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: [Closed] Possibility for WEBP to keep PPI resolution metadata info when saving lossless + size optimized ?

Post by porg »

I summarize:

In a PNG the resolution may be stored in its IFD0 and PNG-pHYs fields or in XMP.

In a WEBP the resolution info can only be contained within Exif or XMP chunks.

Hence if you want resolution info in a WEBP file, not in XMP as this has a rather large minimum size, then under the format options you need to tick Exif ON and below also tick its sub-option "Always generate Exif to save the resolution" which will ensure that if the source file had no Exif to copy over, GC will create a minimal Exif chunk and fill it with the resolution info it determined for the source file.
Post Reply