Comment by crote
17 hours ago
I think the bigger driver is that, due to it being the next PDF image format, most platforms will already be forced to add some form of support to it.
When literally every OS already comes with a form of libjxl pre-installed there is no good reason not to add support for it.
> you just truncate the output stream at the right proportion of pixel data
Does the format have explicit support for this? As in, is there any easy way to do, say, an exact Range request after reading the file header?
> due to it being the next PDF image format
Oh, they finally ratified that? Excellent. This is news to me. You have a link?
That doesn’t seem related to the codec itself but rather how you fetch said image.
Worst case scenario you should be able to add some smarts to the server and a query string such that the client can request 5% of the file or whatever simply by fiddling with the url.
Yes, but figuring out the "5% of the file or whatever" is the hard part!
Let's say JXL does progressive decoding by encoding the image as a checkerboard (it doesn't but for the sake of argument): First you send the average of each 8x8 block, then you send the adjustments needed for the 4x4 blocks within that, then you send the adjustments needed for 2x2, and then 1x1.
If the client knows that it is going to display the image at a low resolution, anything beyond 8x8 might be completely useless, so it would be valuable to know where the 8x8 section starts and the 4x4 section begins. Under-guess and you don't have all the data needed to display it, over-guess and you're fetching data you are going to throw away.
This makes it very useful if it is trivial to analyze the image to determine that, say, the first 5kB are needed for 500x500px display, the first 150kB are needed for 1000x1000px display, and the full 500kB for 2000x2000px and above - either to dynamically generate a <picture> srcset server-side, or to have the browser determine when to abort the fetch after parsing its header.
Knowing where to truncate before you get there is related to the codec itself. Can I figure out where the quarter resolution data ends from the header alone?