gdal icon indicating copy to clipboard operation
gdal copied to clipboard

JPEGXL & JXL-in-TIFF: preserve Alpha color interpretation when the Alpha band does not immediately follow color bands

Open rouault opened this issue 3 years ago • 2 comments

(e.g. R,G,B,undefined,Alpha)

  • JXL-in-TIFF: check on reading consistency between JXL extra channel info and ExtraSamples TIFF tag

rouault avatar Sep 21 '22 20:09 rouault

CC @tbonfort

rouault avatar Sep 21 '22 20:09 rouault

please let me review this before merging the tif part

tbonfort avatar Sep 22 '22 06:09 tbonfort

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 avatar Sep 23 '22 07:09 tbonfort

@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 avatar Sep 26 '22 15:09 rouault

@rouault agreed. LGTM once my suggestion correcting a typo is applied.

tbonfort avatar Sep 26 '22 15:09 tbonfort