Added reading of JPEG2000 comments by radarhere · Pull Request #6909 · python-pillow/Pillow

#6903 adds writing of JPEG2000 comments, so I thought it would be helpful to also be able to read JPEG2000 comments.

Looking at image data, I saw that shortly after _parse_jp2_header() had seeked forward in the file, there was "jp2c", signalling a "Contiguous codestream box". The next bytes were b"\xff\x4f\xff\x51", as Pillow checked for a few lines earlier before running _parse_codestream().

So using _parse_codestream() as a basis, this PR reads the type of the marker, the length, and the rest of the data in the marker, until reaching a "comment" marker, or breaking if the data ends, or if "start of tile" or "end of codestream" is reached first. See https://github.com/corkami/formats/blob/master/image/jpeg.md#jpeg-2000 for the marker types.

I've added a test image, just saved with Pillow.