This has been fixed on master of jpeg-decoder (https://github.com/kaksmet/jpeg-decoder/pull/94) but jpeg-decoder hasn't published a new version to crates.io yet. I'm not sure what the right thing to do about that is. I assume it's incorrect to depend on a specific commit in their repo, instead of a published version. It might be possible to reach out to the owner of jpeg-decoder and ask him to publish a new version. Regardless, I feel there should be something tracking this issue on the main image crate. Most people who encounter this will not be aware of the details of the JPEG format, and will come here first.
I encountered it by trying to load a JPG produced by my Samsung smartphone; the user who fixed it in jpeg-decoder discovered it in a similar way.
JPEG images with zero-length DHT segments are parsed correctly. There's an example in the PR linked above.
Such images fail to load with errors like
ImageError { error: FormatError("encountered APP(5) with invalid length 2") }
Try to load the image linked in the above PR.
jpeg-decoder 0.1.16 has been published
Most helpful comment
jpeg-decoder 0.1.16 has been published