Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion .github/workflows/publishwheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,57 @@ on:
- "v*.*.*" # Triggers only for version tag pushes

jobs:
sdist:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain what this flow does?

name: Build source distribution and upload
runs-on: ubuntu-latest

steps:
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Create virtual environment
shell: bash
run: |
python -m venv .venv
if [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate
else
source .venv/Scripts/activate
fi
python -m pip install --upgrade pip maturin

- name: Build wheel
shell: bash
run: |
if [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate
else
source .venv/Scripts/activate
fi

cd python
maturin build --sdist

- name: Upload to TestPyPI
shell: bash
run: |
if [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate
else
source .venv/Scripts/activate
fi

cd python
maturin upload --skip-existing $GITHUB_WORKSPACE/target/wheels/*
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

build:
name: Build and upload wheels
name: Build plaform binaries and upload wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,35 @@ This is a port of the C++ Lepton JPEG compression tool that was released by Drop

With precise bit-by-bit recovery of the original JPEG, the Lepton compression library is designed for lossless compression of baseline and progressive JPEGs up to 22%. JPEG storage in a cloud storage system is the main application case. Even metadata headers and invalid content are kept in good condition.


## How to Use This Library
Some operations of this library are vectorized such as the IDCT using the [Wide](https://crates.io/crates/wide) crate, so you can get a significant boost if you enable +AVX2.

#### Building From Source
### Rust

The libary is published on crates.io as [lepton_jpeg](https://crates.io/crates/lepton_jpeg).

### Python

The library is published on PyPI as *lepton_jpeg_python*.

```
pip install lepton_jpeg_python
```

``` Python
import lepton_jpeg_python

with open("../images/slrcity.jpg", "rb") as f:
jpg_data = f.read()

compressed = lepton_jpeg_python.compress_bytes(jpg_data, config)
decompressed = lepton_jpeg_python.decompress_bytes(compressed, config)

assert jpg_data == decompressed
```

### Building From Source

- [Rust 1.65 or Above](https://www.rust-lang.org/tools/install)
- [Rust 1.88 or Above](https://www.rust-lang.org/tools/install)

``` bash
git clone https://github.com/microsoft/lepton_jpeg_rust
Expand All @@ -21,9 +43,11 @@ cargo test
cargo build --release
```

#### Running
Some operations of this library are vectorized such as the IDCT using the [Wide](https://crates.io/crates/wide) crate, so you can get a significant boost if you enable +AVX2.

### Executable

There is an `lepton_jpeg_util.exe` wrapper that is built as part of the project. It can be used to compress/decompress and also to verify the test end-to-end on a given JPEG. If the input file has a `.jpg` extension, it will encode. If the input file has a `.lep` extension, it will decode back to the original`.jpg`.
Building the Rust project generates an `lepton_jpeg_util.exe` wrapper that is built as part of the project. It can be used to compress/decompress and also to verify the test end-to-end on a given JPEG. If the input file has a `.jpg` extension, it will encode. If the input file has a `.lep` extension, it will decode back to the original`.jpg`.

It supports the following options:

Expand Down