matt.baker
matt.baker

Reputation: 256

JPEG and PNG metadata compression

Does either JPEG or PNG support compression of metadata/ancillary data?

Everything I've read so far focusses on the image compression and I can't find any mention of extended data compression.

The reason I ask is that metadata was shown to contribute to ~16% on average across a number of JPEG files, but if it was compressed this could be a lot less.

Most compression software seems to remove the metadata, but is it possible to compress it instead?

Upvotes: 1

Views: 851

Answers (1)

Harald K
Harald K

Reputation: 27084

JPEG (or JIF-based formats, like JFIF or Exif) typically contain:

  • Exif metadata (which is a TIFF structure), can only be uncompressed (except for the embedded thumbnail which can be JPEG-compressed), as per TIFF 6.0 spec
  • XMP metadata (as a UTF-serialized XML document), could probably be compressed, but it's not according to the XMP spec.
  • COM markers, plain text only
  • JFXX extension, which can hold a JPEG-compressed thumbnail, of limited use
  • ICC_PROFILE (ICC Profile) uncompressed only (as per ICC spec)
  • Adobe Photoshop IRBs, uncompressed (as per Phothoshop format spec).

PNG typically contain:

  • tEXt, iTXt and zTXt chunks. The zTXt chunk is compressed using zLib (same as the PNG pixel data), and iTXt can be compressed as well.
  • XMP in PNG is defined to use the iTXt chunk type, but the spec only mentions uncompressed (as per XMP spec). You may be able to compress this, but I'm not sure if it's really allowed.
  • iCCP (ICC Profile) uncompressed only (as per ICC spec)

In other words, yes, you could compress it, but most of the time, the data would no longer be readable by software written to follow the mentioned specifications. Thus, it's not really practical.

Upvotes: 3

Related Questions