Support for progressive JPEGs in LibGfx is brought by #17907.
However, it doesn't have support for at least one edge case: images with huge end-of-bands. Indeed, a normal EOB marker can only embed a value of, at maximum, 32 767. But some images might need to encode more than that.
As specified in G.1.2.2 Progressive encoding of AC coefficients with Huffman coding
:
If an EOB run is greater than 32 767, it is coded as a sequence of EOB runs of length 32 767 followed by a final EOB run sufficient to complete the run.
This is something that happens to work on baseline JPEGs and SOF2 with spectral selection only. In other words, it only fails with progressive JPEGs.
add_ac
and read_eob
functions in JPEGLoader.cpp
JPEGLoader.h
)I created a 1500x1500 uniform image in GIMP and exported it in .ppm (a format that cjpeg can read), then I created the final image with cjpeg -progressive
.
My bad, this method doesn't work as cjpeg
seems to hit another condition before reaching an EOB of 32768. A few other things to try:
cjpeg
compilation optionsI added the good first issue
label, as this issue can probably be fixed in less than 10 lines. However, it probably requires a bit more than common knowledge (read that as you will need to read the spec) to understand what you're doing.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too