Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jxl support #43

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
197 changes: 191 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ av-metrics-decoders = { version = "0.3.1", features = [
clap = { version = "4.0.18", features = ["derive"] }
crossterm = "0.27.0"
indicatif = "0.17.1"
jxl-oxide = { version = "0.10.1", features = ["image"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

This increases binary size from 3.4M to 6.0M on my machine.. Should probably be a feature.

num-traits = { version = "0.2.15", optional = true }
ssimulacra2 = { version = "0.5.0", default-features = false }
statrs = { version = "0.17.0", optional = true }
Expand Down
25 changes: 23 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,29 @@ fn main() {

fn compare_images(source: &Path, distorted: &Path) {
// For now just assumes the input is sRGB. Trying to keep this as simple as possible for now.
let source = image::open(source).expect("Failed to open source file");
let distorted = image::open(distorted).expect("Failed to open distorted file");
let source = if let Ok(image) = image::open(source) {
image
} else if let Ok(decoder) = jxl_oxide::integration::JxlDecoder::new(
FreezyLemon marked this conversation as resolved.
Show resolved Hide resolved
std::fs::File::open(source)
.ok().expect("could not open source file"),
) {
image::DynamicImage::from_decoder(decoder)
.ok().expect("failed to decode source jxl")
} else {
panic!("Failed to open the source file")
};

let distorted = if let Ok(image) = image::open(distorted) {
image
} else if let Ok(decoder) = jxl_oxide::integration::JxlDecoder::new(
std::fs::File::open(distorted)
.ok().expect("could not open distorted file"),
) {
image::DynamicImage::from_decoder(decoder)
.ok().expect("failed to decode distorted jxl")
} else {
panic!("Failed to open the distorted file")
};

let source_data = source
.to_rgb32f()
Expand Down
Loading