My ranking of the APIs of various image decoding libraries:
1. stb_image tier: libwebp
Call a function. You're done.
2. Good tier: libheif (also handles avif)
A bunch of functions you need to call in sequence, all presented as a neat and short program in the README.
3. Okay tier: libpng, libjpeg.
You have to go through a narrated guide on what to call. You can get the work done, but you have to wade through super important stuff like low-quality decoding in case you want to run on Amiga.
4. Crap tier: libjxl
You get doxygen docs, so you don't know where to start. The example program is your best bet, but it is convoluted and outputs each color channel as a float.
The documentation is sometimes vague. To check if a file might be JPEG XL, you have to provide "the beginning of the file". The function may fail and ask for more data. The documentation never specifies how much is needed.
Reading the source code shows that it's 12 bytes.
The decoding process requires repeated calls to JxlDecoderProcessInput. The documentation lists several return codes you must handle.
You start to build up a mental map of how all of this is supposed to work, and then you realize that some of it does not make any sense at all.
Then you read the source code and find out that the decoding function can actually return a much wider variety of return codes, but the documentation does not tell you that.
@wolfpld and then a separate category is LibTIFF that does things like getenv deep from within library functions. Getenv does not even exist on some platforms I need LibTIFF on…
@aras I did a quick look and these seem to be some internal configuration options? Which is great, your program might suddenly fail because a variable has been set somewhere.
You can just remove those calls, but oh no, you're now maintaining a fork of a 35 year old library that had the latest release... let's see... 2 weeks ago.
And the release notes explicitly state that some tools will no longer be supported because they have security problems that no one wants to fix.
Oh, wow.
@wolfpld “maintaining a fork”, you don’t say https://github.com/aras-p/libtiff/commit/921ecd5f2eb4aab76f589c1db7bb2264befc02c1