Re: Location of XMP in PNG image

Cosmin Truta <[email protected]> Fri, 12 Apr 2019 00:55:12 -0400
Newsgroups gmane.comp.graphics.png.general
Message-ID <CAAoVtZyBidS3DMV12Yxf5zWt_nNXJRjN5kAfVGYwymaTTreZug@mail.gmail.com>
On Thu, 11 Apr 2019 at 09:00, Phil Harvey wrote:
> In a PNG image, the XMP uses an iTxt chunk, which according
> to my reading of the specification may occur anywhere before
> IEND.  Is this correct?

Yes, it is correct that iTXt may appear anywhere. Applications may
impose additional restrictions on the chunk's content, and are free to
ignore such content as they please, but that is not the case with XMP.

> The XMP specification states:
> "Encoders are encouraged to place the chunk at the beginning
> of the file, but this is not required."

Indeed.

> But a single-pass metadata editor (such as ExifTool) must
> write the XMP as late a possible to avoid the possibility
> of writing duplicate or conflicting metadata.  As a result,
> by default ExifTool writes the XMP chunk just before IEND.

This is an understandable restriction.

> The problem is that Photoshop seems to ignore XMP if it
> comes after the IDAT chunk, but as far as I know this
> should be perfectly valid.

This is very unfortunate, especially considering that the XMP support
in PNG had been drafted and proposed to our group by somebody from
Adobe.

I understand the desire to place the metadata at the beginning,
considering that it can be inspected without the need to load or
download the whole image file. Especially if that image is coming on a
wire, or if random file access is otherwise unavailable. But that's a
non-normative recommendation. If Photoshop is ignoring XMP trailing
IDAT, that's a bug.

File a bug report, perhaps?

Sincerely,
Cosmin