In 1993 a JPEG standard amendum defined a way to create a "lossless" variant of JPEG. The methodology is roughly: encode fullsize channels as RGB (not YCrCb) and include a set of corrections with the channel to compensate for errors. This encoding is not widely used, but is supported by PVRG JPEG.
Using PVRG JPEG with my PGM output patch, it is easy to decode a lossless JPEG. At least for the one example of "lossless JPEG" I have. The channels decode in RGB order, but the component numbers are not sequential or in ascending order, so you need to pay attention to the output.
Test files found in a "Lossless JPEG patch for IJG libjpeg 6b" archive, but of unknown license and provenance:
$ jpeg -d -g -s ljpeg-6b-testimgl.jpg -o lossless-part > GlobalWidth:227 GlobalHeight:149 ResyncInverval:0 >> C:82 N: lossless-part.82.pgm W: 227 H: 149 hf:1 vf:1 >> C:71 N: lossless-part.71.pgm W: 227 H: 149 hf:1 vf:1 >> C:66 N: lossless-part.66.pgm W: 227 H: 149 hf:1 vf:1 $ rgb3toppm lossless-part.82.pgm lossless-part.71.pgm lossless-part.66.pgm \ > lossless-whole.ppm $ md5sum ljpeg-6b-testimgl.ppm lossless-whole.ppm c04a128004e5f293b67518562fe1954e ljpeg-6b-testimgl.ppm c04a128004e5f293b67518562fe1954e lossless-whole.ppm $
This web page is by Eli the Bearded / Benjamin Elijah Griffin. Page copyright July 2015, reproduction of text, my code, and images is permitted under the Creative Commons Attribution-ShareAlike License.