Skip to content

Commit

Permalink
chore: Update how docs are generated (#73)
Browse files Browse the repository at this point in the history
- Prepare changelog for release-plz
- Enable parallel builds on Windows
  • Loading branch information
inflation authored Aug 15, 2024
1 parent 52cc720 commit b88be46
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 473 deletions.
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# Basic set up for Cargo projects

---
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: "weekly"
commit-message:
prefix: "️👷 "
include: scope

# Maintain dependencies for Cargo
Expand All @@ -19,5 +16,4 @@ updates:
schedule:
interval: weekly
commit-message:
prefix: "⬆️ "
include: scope
34 changes: 17 additions & 17 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ jobs:
name: Release-plz
runs-on: ubuntu-latest
steps:
- name: Generate GitHub token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@main
env:
- name: Generate GitHub token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@main
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "libjxl"]
path = jpegxl-src/libjxl
url = https://github.com/libjxl/libjxl
branch = refs/tags/v0.10.3
25 changes: 0 additions & 25 deletions Justfile

This file was deleted.

47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ Currently, `u8`, `u16`, `f16` and `f32` are supported as pixel types.
### Decoding

```rust
let mut decoder = decoder_builder().build()?;
let (Metadata { width, height, ..}, pixels) = decoder.decode(&sample)?;
use jpegxl_rs::*;
use jpegxl_rs::decode::*;

let mut decoder = decoder_builder().build().unwrap();
let sample = include_bytes!("../../samples/sample.jxl");

let (Metadata { width, height, ..}, pixels) = decoder.decode(sample).unwrap();
match pixels {
Pixels::Float(data) => { /* do something with Vec<f32> data */ },
Pixels::Uint8(data) => { /* do something with Vec<u8> data */ },
Expand All @@ -39,7 +44,8 @@ use jpegxl_rs::ThreadsRunner;
let runner = ThreadsRunner::default();
let mut decoder = decoder_builder()
.parallel_runner(&runner)
.build()?;
.build()
.unwrap();

// Customize pixel format
let mut decoder = decoder_builder()
Expand All @@ -48,39 +54,42 @@ let mut decoder = decoder_builder()
endianness: Endianness::Big,
align: 8
})
.build()?;
.build()
.unwrap();

decoder.decode_with::<u8>(&sample);
decoder.decode_with::<u8>(sample);

// You can change the settings after initialization
decoder.skip_reorientation = Some(true);

// Reconstruct JPEG, fallback to pixels if JPEG reconstruction is not possible
// This operation is finished in on pass
let (metadata, data) = decoder.reconstruct(&sample)?;
let (metadata, data) = decoder.reconstruct(sample).unwrap();
match data {
Data::Jpeg(jpeg) => {/* do something with the JPEG data */}
Data::Pixels(pixels) => {/* do something with the pixels data */}
}

```

### Encoding

```rust
use image::io::Reader as ImageReader;
let sample = ImageReader::open("../samples/sample.png")?.decode()?.to_rgba16();
let mut encoder = encoder_builder().build()?;
let buffer: EncoderResult<f32> = encoder.encode(&sample, sample.width(), sample.height())?;
```
use image::ImageReader;
use jpegxl_rs::encoder_builder;
use jpegxl_rs::encode::{EncoderResult, EncoderSpeed};

Set encoder options
let sample = ImageReader::open("../samples/sample.png").unwrap().decode().unwrap().to_rgba16();
let mut encoder = encoder_builder().build().unwrap();

```rust
let buffer: EncoderResult<f32> = encoder.encode(&sample, sample.width(), sample.height()).unwrap();

// Set encoder options
let mut encoder = encoder_builder()
.lossless(true)
.speed(EncoderSpeed::Falcon)
.build()?;
.build()
.unwrap();

// You can change the settings after initialization
encoder.lossless = false;
encoder.quality = 3.0;
Expand All @@ -95,10 +104,10 @@ use jpegxl_rs::image::ToDynamic;
use jpegxl_rs::decoder_builder;
use image::DynamicImage;

let sample = std::fs::read("../samples/sample.jxl")?;
let mut decoder = decoder_builder().build()?;
let img = decoder.decode_to_image(&sample)?;
let img = decoder.decode_to_image_with::<f32>(&sample)?;
let sample = std::fs::read("../samples/sample.jxl").unwrap();
let mut decoder = decoder_builder().build().unwrap();
let img = decoder.decode_to_image(&sample).unwrap();
let img = decoder.decode_to_image_with::<f32>(&sample).unwrap();
```

License: GPL-3.0-or-later
Loading

0 comments on commit b88be46

Please sign in to comment.