gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Support more than 4 bands for JPEG-XL compression in GEOTIFF

Open RaananHadar opened this issue 3 years ago • 4 comments

Expected behavior and actual behavior.

Currently GEOTIFF with JPEG-XL compression in GDAL support up to 4 bands, while the standard supports up to 4100 channels. This extremely important for many multi-spectral satellites that require more than 4 bands: LANDSAT, Sentinel-2, Maxar...).

I will also note that this, to my understanding is the biggest hurdle for many end users to seriously consider JPEG-XL over J2K.

Many thanks 🙏

RaananHadar avatar May 11 '22 03:05 RaananHadar

From my testing, the encoder side of libjxl limits to 4 channels currently, that is in a single codestream. If you use the -co INTERLEAVE=BAND creation option of the GeoTIFF driver, each band will be compressed as a single JPEGXL codestream, so you can handle an arbitrary number of them

rouault avatar May 11 '22 09:05 rouault

libjxl has recently added support for more than 4 bands in a single codestream (i.e. for INTERLEAVE=PIXEL) however I'm not sure their API around that has stabilized yet, and how the compression ratios compare to INTERLEAVE=BAND. Adding this support to gdal/gtiff is definitely on my todo list

tbonfort avatar May 11 '22 09:05 tbonfort

libjxl has recently added support for more than 4 bands in a single codestream (i.e. for INTERLEAVE=PIXEL)

well, I tried to use the API for extra channels for the queued standalone JPEGXL driver (https://github.com/OSGeo/gdal/pull/5692) with latest libjxl, but I failed to make it work. Not sure if I misuse the API, or libjxl isn't ready yet.

rouault avatar May 11 '22 09:05 rouault

I just figured out how to use libjxl extra channel API: https://github.com/OSGeo/gdal/pull/5692/commits/375ebd92e2edcb6bb7ba4a5f76929a856499e5ab

rouault avatar May 11 '22 14:05 rouault