JPEGXL & JXL-in-TIFF: preserve Alpha color interpretation when the Alpha band does not immediately follow color bands
(e.g. R,G,B,undefined,Alpha)
- JXL-in-TIFF: check on reading consistency between JXL extra channel info and ExtraSamples TIFF tag
CC @tbonfort
please let me review this before merging the tif part
From the discussion in https://github.com/libjxl/libjxl/issues/1773#issuecomment-1254981545_ about how band ordering in jxl should not be interpreted by index but rather by name, which implies that the jxl encoder /may/ be allowed to reorder the bands if we set their type to something other than JXL_CHANNEL_OPTIONAL, I'm not overly confident that we should be setting/checking that type in the tif codec, as the source of truth for the band interpretation is the tif header, not the jxl metadata. What do you think?
@tbonfort Given the last answer in the libjxl ticket "-Would the encoder be allowed to reorder bands ? - I don't think the encoder should be allowed to do that, and the current libjxl encoder certainly doesn't.", it seems to me that this PR should be safe. That said, I can disable the part in tif_jxl.c that checks the consistency of the TIFF ExtraSample tag with the type of the libjxl extra channels. It seems to me that giving an hint to the encoder that a channel is alpha should help it to do potentially a better job.
@rouault agreed. LGTM once my suggestion correcting a typo is applied.