Skip to content

Commit

Permalink
support jpeg reconstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
Isotr0py committed Feb 1, 2024
1 parent 43dbd4f commit 6ab6545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/target
Cargo.lock
*.ipynb
*.jxl
*.jpeg

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
12 changes: 9 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pyo3::prelude::*;
use pyo3::types::PyBytes;

use jpegxl_rs::decode::{Metadata, Pixels};
use jpegxl_rs::decode::{Metadata, Pixels, Data};
use jpegxl_rs::encode::EncoderResult;
use jpegxl_rs::parallel::threads_runner::ThreadsRunner;
use jpegxl_rs::{decoder_builder, encoder_builder};
Expand Down Expand Up @@ -145,9 +145,15 @@ impl Decoder {
}
false => decoder_builder().build().unwrap(),
};
let (info, img) = decoder.decode(&data).unwrap();
// let (info, img) = decoder.decode(&data).unwrap();
// let img: Vec<u8> = match img {
// Pixels::Uint8(x) => x,
// _ => panic!("Unsupported dtype for decoding"),
// };
let (info, img) = decoder.reconstruct(&data).unwrap();
let img: Vec<u8> = match img {
Pixels::Uint8(x) => x,
Data::Jpeg(x) => x,
Data::Pixels(Pixels::Uint8(x)) => x,
_ => panic!("Unsupported dtype for decoding"),
};
(ImageInfo::from(info), PyBytes::new(_py, &img))
Expand Down

0 comments on commit 6ab6545

Please sign in to comment.