Exploring JPEG-XL

In order to optimize (and reduce) the storage needs, we’re currently exploring the pro and cons to use JPEG-XL (JXL) instead of JPEG for Panoramax.

JPEG-XL has many interesting features:

  • lossless conversion from and back to JPEG (bit perfect)
  • more efficent compression (20% saving on JPEG lossless)
  • tiling up to 1024x1024 pixels
  • progressive decompression
  • HDR support

On 360° pictures, we could save 60% of storage and still 20% on non 360 pictures !

Of course, to support viewers that are not JXL compatible (all of them right now), some fallback is required to provide JPEG content and not only JXL.

One possible scenario could be:

  • upload in JPEG or JXL
  • lossless conversion of JPEG to JXL (this allows to retrieve the original JPEG)
  • directly serve JXL for compatible viewers
  • on demand reverse conversion to JPEG for incompatible viewers and backward compatibility

thumbnails could be store in JPEG as they consume marginal storage.

The on-demand conversion would provide:

  • low definition version (taking advantage of progressive JLX decompression)
  • tiles generation (taking advantage of large JXL tiles)
  • original JPEG conversion

JXL compatible viewers would need to be smart enough to take advantage of the “cloud optimized” nature of JXL. By requesting byte ranges from the single JXL file, it is possible to directly access and transfer only the part that are needed for display, including a low resolution and tiles.
Of course, this means more development that simply being able to display JXL but this can make the viewer more responsive and limit the amount of data tranfered over the network.

On demand conversion means CPU resources, which are linked to how frequent pictures are used, some cache could reduce the load on some images that are frequently accessed.
If Panoramax default viewer support JXL directly, this will limit the need for additional CPU resources at the server level.

On the other side, storage is linked to how many pictures are available, independently of the viewer and we know that this is constantly increasing and is the cotsy part of runing a Panoramax instance.

libjxl has been greatly improved and now provides quite fast processing by using SIMD AVX code optimized for today’s CPUs.
On large JPEG pictures (96Mpx), the tests are showing that a full reverse conversion to JPEG areusually below 1s (single thread) and even lower in multi-thread.

One more thing :wink:

When JPEG is lossly recompressed to JXL, the gain in size can be much higher with typically -60% instead of -20% !
This could be used on older pictures to keep as archives with some loss.

2 Likes

Within the navigators

1 Like

On the last month on logs from IGN and OSM-FR instance and the meta-catalog we have:

  • around 80% where support is there but not enabled by default (a simple config change is needed)
  • 7% where it is supported (Safari)
  • 73% using recent versions of their browser (N or N-1), where we can expect a quick upgrade to N+1 version…

It is clear that a switch to JXL will need to wait for more adoption, and in any case a JPEG retro-compatibility is needed also for non in-browser uses.

It appears clear that 1. the gains are really substantial 2.the full switch won’t be for tomorrow due to compatibility issues.

To move forward with this in mind and as the JPEG-XL is lossless, I believe we should consider to use it for backup.

The idea would be for any instance admin willing to contribute to host its own pictures in JPEG and also as many pictures in JPEG-XL from other instances.

The conversion from JPEG to JPEG-XL and back to JPEG is lossless, this is a big difference and something very specific to JPEG-XL.

There is a real lossless mode in JPEG-XL (like in JPEG) too but the compression ratio becomes very low and not used unless in very specific cases.

For backups, we could also consider a full recompression into JPEG-XL that would not be lossless that will save much more storage than 20%.

It will take time to convert them back to JPEG, but more or less similar to a lossless conversion.
I can check on the backups I’m doing on “small” instances to see how much can be saved with both options.