Skip to content

Incompatibility with non-EOI #177

@nolmoonen

Description

@nolmoonen

Similarly to #176, JPEGs that do not have an EOI marker are handled differently by Dropbox' implementation than by this project. At least, that is the case for at least one JPEG file: https://github.com/chromium/chromium/blob/86c0558b56747cc893a4984f743c22f317c7c2bd/third_party/blink/web_tests/images/resources/half_scan.jpg.

On the latest release (v0.5.3) it seems to compress fine but decompressing with Dropbox' implementation results in a JPEG where the final two bytes are EOI instead of the actual data:

./lepton_jpeg_util half_scan.jpg half_scan.jpg.lep
./lepton half_scan.jpg.lep # produces half_scan.jpg.jpg
colordiff -y <(xxd half_scan.jpg) <(xxd half_scan.jpg.jpg)
00000000: ffd8 ffe0 0010 4a46 4946 0001 0100 0001  ......JFIF   00000000: ffd8 ffe0 0010 4a46 4946 0001 0100 0001  ......JFIF
00000010: 0001 0000 ffdb 0084 0001 0101 0101 0101  ..........   00000010: 0001 0000 ffdb 0084 0001 0101 0101 0101  ..........
(truncated)
00000a90: 1101 0000 0000 0000 0000 0000 0000 0000  ..........   00000a90: 1101 0000 0000 0000 0000 0000 0000 0000  ..........
00000aa0: 00c0 ffda 0008 0103 0101 3f01 4ab7       .......... | 00000aa0: 00c0 ffda 0008 0103 0101 3f01 ffd9       ..........

So the v0.5.3 seems to produce a Lepton file that is not completely compatible with the ones produced by the original implementation.

On current main (adf4f4a) this project fails to compress the file, stating that the verification failed:

lepton_jpeg_util half_scan.jpg half_scan.jpg.lep
2026-01-19T12:20:23.051Z INFO  [lepton_jpeg::structs::lepton_file_writer] compressing to Lepton format
2026-01-19T12:20:23.053Z INFO  [lepton_jpeg::structs::lepton_file_writer] Number of threads: 1
2026-01-19T12:20:23.061Z INFO  [lepton_jpeg::structs::lepton_file_writer] worker threads 7ms of CPU time in 8ms of wall time
2026-01-19T12:20:23.062Z INFO  [lepton_jpeg::structs::lepton_file_writer] decompressing to verify contents
2026-01-19T12:20:23.071Z ERROR [lepton_jpeg_util] error VerificationContentMismatch: ERROR mismatching data (but same size)
 at lib/src/structs/lepton_file_writer.rs:112:16
error code: VerificationContentMismatch 1005 ERROR mismatching data (but same size)
 at lib/src/structs/lepton_file_writer.rs:112:16

Which is much nicer, though a perfect solution would be for this project to also support such files (I haven't looked myself if that is possible in the first place).

As a side-note: this issue and the one from #176 were found by testing with a large number of problematic files, of which only two cases caused issues, which is great to see :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions