dropbox / lepton

Lepton is a tool and file format for losslessly compressing JPEGs by an average of 22%.
https://blogs.dropbox.com/tech/2016/07/lepton-image-compression-saving-22-losslessly-from-images-at-15mbs/
Apache License 2.0
5.01k stars 355 forks source link

Lepton fails roundtrip validation on some JPEGs #97

Closed onethumb closed 6 years ago

onethumb commented 7 years ago

On certain JPEGs that other pieces of software think are well-formed, Lepton fails validation:

$ ./lepton broken.jpg
lepton v1.0-209463ae36042dbd29864526f739ad851a60757d
53631075 bytes needed to decompress this file
2363042 2788054
84.76%
49478836 bytes needed to decompress this file
2363042 2788054
84.76%
Input Size 2788054 != Roundtrip Size 2788054
c2bee1567f6d9be3ffd9aa900159374f != 29d269a42fe8cf908c9304ef33d8d34b
ROUNDTRIP_FAILURE

Other JPEG-related commands work fine, such as jpeginfo, seem to work fine:

![jpeg-produces-strange-lepton-errors](https://user-images.githubusercontent.com/569776/27805604-864e1074-5fea-11e7-891e-5a6b99984458.jpg)
![jpeg-produces-strange-lepton-errors-2](https://user-images.githubusercontent.com/569776/27805607-89d04370-5fea-11e7-8039-afd41410a14d.jpg)
$ jpeginfo -c broken.jpg
broken.jpg 2967 x 2007 24bit Exif  P 2788054  [OK]

ImageMagick identify -verbose doesn't detect any errors. Browsers, Photoshop, etc, all seem to operate fine, as does our internal tooling.

jpegtran operations work (-optimize, -progressive, etc). After jpegtran execution, Lepton works on the resulting output.

When -skipvalidate is used with Lepton, it produces the expected invalid JPEG.

Example Photo 1: https://www.dropbox.com/s/4sufy9ws3scvovx/jpeg-produces-strange-lepton-errors.jpg?dl=0 Example Photo 2: https://www.dropbox.com/s/avgfd4s2wbuzlue/jpeg-produces-strange-lepton-errors-2.jpg?dl=0

danielrh commented 7 years ago

Thanks for the report... it seems that your progressive image had the scans in an unexpected order and lepton rearranged them, producing a pixel-exact result, but not a roundtripping bit-exact result. Unfortunately most of the quality control was done with the -rejectprogressive command line, which would simply have banned this file

it's probably a minor change to serialize out the ordering somewhere in the file...feel free to submit a pull request if you'd like to improve the tool in this way.

danielrh commented 6 years ago

Can you try downloading master and passing lepton the -permissive flag?

danielrh commented 6 years ago

re-open if you're still experiencing an issue with the -permissive flag