Location of XMP in PNG image

Phil Harvey <phil-CIeU6mJ2MbMd166Dz3SrqbDks+cytr/[email protected]> Thu, 11 Apr 2019 08:45:18 -0400
Newsgroups gmane.comp.graphics.png.general
Message-ID <[email protected]>
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?

The XMP specification states:

"Encoders are encouraged to place the chunk at the beginning
of the file, but this is not required."

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.

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.

- Phil