Dropbox recently released Lepton (GitHub), a method that losslessly compresses JPEG images round-trip, saving an average of 22%.
Because of the pigeonhole principle, any general compression algorithm cannot be guaranteed to result in a smaller file (general because it doesn't apply to inputs constrained to a specific format). Lepton exploits common characteristics about JPEGs, which if subverted, might pigeonhole it to produce a file larger than the source.
Requirements
Write a program that generates:
- A valid JPEG/JFIF image,
- with a size between 0.5 MB and 1 MB,
- no smaller than 256 × 256 px,
- no larger than 4096 × 4096 px,
- recognizable by Lepton (it can successfully "compress" to a
.lep
image), and - decompresses to an identical
.jpg
(as the input). APPx
,COM
, and other metadata, non-graphical marker sections are restricted in the JPEG (injecting arbitrary amounts of random bytes into the image to asymptotically approach 1:1 compression is lame.)- an
APP0
JFIF marker is permitted but no thumbnail is allowed (should be exactly 16 bytes) - tl;dr If you're not intentionally shoving metadata into an EXIF segment and you disable any sort of thumbnail your language library of choice wants to put into the image, that should be OK.
- an
Post the code and image.
If you want to write a program that produces a Lepton image that when converted yields a JPEG meeting the criteria, that's fine. It must remain identical across arbitrarily many JPEG → Lepton → JPEG → ... cycles.
Scoring
The byte size of the Lepton image divided by the source JPEG image. Higher (worse Lepton compression) is better. Run Lepton with default flags and switches.
Getting Lepton
A 5-second crash-course to build Lepton:
git clone https://github.com/dropbox/lepton.git
cd lepton
./autogen.sh && ./configure && make
# fish shell: ./autogen.sh ;and ./configure ;and make
Then ./lepton --help
should tell you things.