Recent

Author Topic: Lepton reader and writer for Lazarus  (Read 576 times)

Tomxe

  • New Member
  • *
  • Posts: 46
Lepton reader and writer for Lazarus
« on: March 04, 2025, 02:29:23 am »
Lepton is a JPEG repacker created by Dropbox but they cancelled the project.
Microsoft took the project and rewritten in Rust.

Lepton can recompress JPEG images to 20-30% smaller .LEP files and those .LEP files can be unpacked to get byte-by-byte identical JPEG images. So it works kinda like ZIP or RAR.

https://github.com/Xelitan/Lepton-reader-and-writer-for-Delphi-Lazarus
License: MIT

Usage examples- reading:

Code: Pascal  [Select][+][-]
  1. Image1.Picture.LoadFromFile('test.lep');


Writing:

Code: Pascal  [Select][+][-]
  1.     H: TLeptonImage;
  2. begin
  3.   Image1.Picture.LoadFromFile('test.bmp');
  4.  
  5.   H := TLeptonImage.Create;
  6.   H.Assign(Image1.Picture.Bitmap);
  7.   H.SetLossyCompression(44);
  8.   H.SaveToFile('test.lep');
  9.   H.Free;

Packing and unpacking JPEGs:

Code: Pascal  [Select][+][-]
  1. InF := TFileStream.Create('input.jpg', fmOpenRead);
  2. OutF := TFileStream.Create('output.lep', fmCreate);
  3. EncodeLepton(InF, OutF);
  4.  

and:

Code: Pascal  [Select][+][-]
  1. InF := TFileStream.Create('input.lep', fmOpenRead);
  2. OutF := TFileStream.Create('output.jpg', fmCreate);
  3. DecodeLepton(InF, OutF);

Okoba

  • Hero Member
  • *****
  • Posts: 616
Re: Lepton reader and writer for Lazarus
« Reply #1 on: March 05, 2025, 10:25:50 am »
@Tomxe fantastic work!

Boleeman

  • Hero Member
  • *****
  • Posts: 897
Re: Lepton reader and writer for Lazarus
« Reply #2 on: March 05, 2025, 12:26:16 pm »
Fantastic Tomxe for this Lepton reader and writer.

Never heard of this format until now.

Some interesting information on how this format works is here:
https://dropbox.tech/infrastructure/lepton-image-compression-saving-22-losslessly-from-images-at-15mbs

The dropbox people said: "We have used Lepton to encode 16 billion images saved to Dropbox, and are rapidly recoding our older images. Lepton has already saved Dropbox multiple petabytes of space."
Looks like it is a good lossless compression.

Thanks Tomxe  for the Lepton reader and writer.
« Last Edit: March 05, 2025, 12:29:01 pm by Boleeman »

DrakkTheSeafarer

  • Newbie
  • Posts: 6
Re: Lepton reader and writer for Lazarus
« Reply #3 on: March 05, 2025, 12:50:29 pm »
Thank you for sharing this. But is it a "Lossless" Compression procedure (JPEG is not) ?

Tomxe

  • New Member
  • *
  • Posts: 46
Re: Lepton reader and writer for Lazarus
« Reply #4 on: March 05, 2025, 06:16:04 pm »
You can repack JPEG into Lepton losslessy, like ZIP. Then you can repack Lepton back into identical JPEG.

 

TinyPortal © 2005-2018