Skip to content

Commit

Permalink
⬆️ (deps): Update jpegxl-rs requirement from 0.10.4 to 0.11.0 (#66)
Browse files Browse the repository at this point in the history
* ⬆️ (deps): Update jpegxl-rs requirement from 0.10.4 to 0.11.0

Updates the requirements on [jpegxl-rs](https://github.com/inflation/jpegxl-rs) to permit the latest version.
- [Release notes](https://github.com/inflation/jpegxl-rs/releases)
- [Changelog](https://github.com/inflation/jpegxl-rs/blob/master/release-plz.toml)
- [Commits](https://github.com/inflation/jpegxl-rs/commits)

---
updated-dependencies:
- dependency-name: jpegxl-rs
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* deprecate jpegxl-rs thread

* fix CI

* fix sccache linux CI

* fix linux aarch64 CI

* remove failed aarch64 CI

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Isotr0py <[email protected]>
  • Loading branch information
dependabot[bot] and Isotr0py authored Sep 30, 2024
1 parent 3fa5caa commit 9c277ec
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install Plugin
run: |
brew install jpeg-xl
export DEP_JXL_LIB=/opt/homebrew/Cellar/jpeg-xl/0.10.3/lib
export DEP_JXL_LIB=/opt/homebrew/Cellar/jpeg-xl/0.11.0/lib
export DEP_BROTLI_LIB=/opt/homebrew/Cellar/brotli/1.1.0/lib
export DEP_HWY_LIB=/opt/homebrew/Cellar/highway/1.2.0/lib
source venv/bin/activate
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
-e DEP_BROTLI_LIB=${{ github.workspace }}/libjxl/build/third_party/brotli
-e DEP_HWY_LIB=${{ github.workspace }}/libjxl/build/third_party/highway
before-script-linux: |
git clone --recurse-submodules --depth 1 -b v0.10.3 \
git clone --recurse-submodules --depth 1 -b v0.11.0 \
https://github.com/libjxl/libjxl.git
cd libjxl
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
RUST_BACKTRACE: 1
MACOSX_DEPLOYMENT_TARGET: 12.7
# from homebrew
DEP_JXL_LIB: /opt/homebrew/Cellar/jpeg-xl/0.10.3/lib
DEP_JXL_LIB: /opt/homebrew/Cellar/jpeg-xl/0.11.0/lib
DEP_BROTLI_LIB: /opt/homebrew/Cellar/brotli/1.1.0/lib
DEP_HWY_LIB: /opt/homebrew/Cellar/highway/1.2.0/lib
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install Plugin
run: |
brew install jpeg-xl
export DEP_JXL_LIB=/opt/homebrew/Cellar/jpeg-xl/0.10.3/lib
export DEP_JXL_LIB=/opt/homebrew/Cellar/jpeg-xl/0.11.0/lib
export DEP_BROTLI_LIB=/opt/homebrew/Cellar/brotli/1.1.0/lib
export DEP_HWY_LIB=/opt/homebrew/Cellar/highway/1.2.0/lib
source venv/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = { version="0.22.0", features = ["extension-module"] }
jpegxl-rs = { version="0.10.4", features = ["threads"] }
jpegxl-rs = { version="0.11.0" }

[features]
# Enables parallel processing support by enabling the "rayon" feature of jpeg-decoder.
Expand Down
29 changes: 10 additions & 19 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ pub fn convert_pixels(pixels: Pixels) -> Vec<u8> {
}

#[pyclass(module = "pillow_jxl")]
pub struct Decoder {
parallel: bool,
}
pub struct Decoder;

#[pymethods]
impl Decoder {
#[new]
#[pyo3(signature = (parallel=true))]
fn new(parallel: bool) -> Self {
Self { parallel: parallel }
fn new() -> Self {
Self
}

#[pyo3(signature = (data))]
Expand All @@ -87,18 +84,12 @@ impl Decoder {
_py: Python,
data: &[u8],
) -> (bool, ImageInfo, Cow<'_, [u8]>, Cow<'_, [u8]>) {
let parallel_runner: ThreadsRunner;
let decoder = match self.parallel {
true => {
parallel_runner = ThreadsRunner::default();
decoder_builder()
.icc_profile(true)
.parallel_runner(&parallel_runner)
.build()
.unwrap()
}
false => decoder_builder().icc_profile(true).build().unwrap(),
};
let parallel_runner = ThreadsRunner::default();
let decoder = decoder_builder()
.icc_profile(true)
.parallel_runner(&parallel_runner)
.build()
.unwrap();
let (info, img) = decoder.reconstruct(&data).unwrap();
let (jpeg, img) = match img {
Data::Jpeg(x) => (true, x),
Expand All @@ -117,6 +108,6 @@ impl Decoder {
}

fn __repr__(&self) -> PyResult<String> {
Ok(format!("Decoder(parallel={})", self.parallel))
Ok(format!("Decoder"))
}
}
39 changes: 13 additions & 26 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use jpegxl_rs::parallel::threads_runner::ThreadsRunner;

#[pyclass(module = "pillow_jxl")]
pub struct Encoder {
parallel: bool,
num_channels: u32,
has_alpha: bool,
lossless: bool,
Expand All @@ -22,10 +21,9 @@ pub struct Encoder {
#[pymethods]
impl Encoder {
#[new]
#[pyo3(signature = (mode, parallel=true, lossless=false, quality=1.0, decoding_speed=0, effort=7, use_container=true, use_original_profile=false))]
#[pyo3(signature = (mode, lossless=false, quality=1.0, decoding_speed=0, effort=7, use_container=true, use_original_profile=false))]
fn new(
mode: &str,
parallel: bool,
lossless: bool,
quality: f32,
decoding_speed: i64,
Expand All @@ -52,7 +50,6 @@ impl Encoder {
};

Self {
parallel,
num_channels,
has_alpha,
lossless,
Expand All @@ -76,27 +73,17 @@ impl Encoder {
jumb: Option<&[u8]>,
xmp: Option<&[u8]>,
) -> Cow<'_, [u8]> {
let parallel_runner: ThreadsRunner;
let mut encoder_builder = encoder_builder();
let mut encoder = match self.parallel {
true => {
parallel_runner = ThreadsRunner::default();
encoder_builder.set_jpeg_quality(self.quality);
encoder_builder
.parallel_runner(&parallel_runner)
.build()
.unwrap()
}
false => {
encoder_builder.set_jpeg_quality(self.quality);
encoder_builder.build().unwrap()
}
};
let parallel_runner = ThreadsRunner::default();
let mut encoder = encoder_builder()
.parallel_runner(&parallel_runner)
.jpeg_quality(self.quality)
.has_alpha(self.has_alpha)
.lossless(self.lossless)
.use_container(self.use_container)
.decoding_speed(self.decoding_speed)
.build()
.unwrap();
encoder.uses_original_profile = self.use_original_profile;
encoder.has_alpha = self.has_alpha;
encoder.lossless = self.lossless;
encoder.use_container = self.use_container;
encoder.decoding_speed = self.decoding_speed;
encoder.color_encoding = match self.num_channels {
1 | 2 => ColorEncoding::SrgbLuma,
3 | 4 => ColorEncoding::Srgb,
Expand Down Expand Up @@ -141,8 +128,8 @@ impl Encoder {

fn __repr__(&self) -> PyResult<String> {
Ok(format!(
"Encoder(parallel={}, has_alpha={}, lossless={}, quality={}, decoding_speed={}, effort={})",
self.parallel, self.has_alpha, self.lossless, self.quality, self.decoding_speed, self.effort
"Encoder(has_alpha={}, lossless={}, quality={}, decoding_speed={}, effort={})",
self.has_alpha, self.lossless, self.quality, self.decoding_speed, self.effort
))
}
}

0 comments on commit 9c277ec

Please sign in to comment.