diff --git a/Cargo.lock b/Cargo.lock index e6b2c23d..3e513204 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -638,6 +638,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "image-webp" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a84a25dcae3ac487bc24ef280f9e20c79c9b1a3e5e32cbed3041d1c514aa87c" +dependencies = [ + "byteorder", + "thiserror", +] + [[package]] name = "indenter" version = "0.3.3" @@ -697,19 +707,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "libwebp-sys2" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e2ae528b6c8f543825990b24c00cfd8fe64dde126c8288f4972b18e3d558072" -dependencies = [ - "cc", - "cfg-if", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.4.13" @@ -887,12 +884,6 @@ dependencies = [ "siphasher", ] -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - [[package]] name = "png" version = "0.17.13" @@ -1022,11 +1013,10 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "ril" version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb9d89f558ed427b172d6014c4cf3145b506d379df0676b471964dbbbe923ea1" +source = "git+https://github.com/nekowinston/ril?branch=feat/image_webp#29410372508a6b42523a768859e95d7c914b1c06" dependencies = [ "fast_image_resize", - "libwebp-sys2", + "image-webp", "num-traits", "png", ] @@ -1331,12 +1321,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" diff --git a/catwalk/Cargo.toml b/catwalk/Cargo.toml index d4b40c2e..3b1b4655 100644 --- a/catwalk/Cargo.toml +++ b/catwalk/Cargo.toml @@ -21,19 +21,19 @@ crate-type = ["cdylib", "rlib"] [dependencies] thiserror = "1" +[dependencies.ril] +git = "https://github.com/nekowinston/ril" +branch = "feat/image_webp" +default-features = false +features = ["png", "resize", "webp-pure"] + [target.'cfg(not(target_family = "wasm"))'.dependencies] clap = { version = "4", features = ["derive"] } clap_complete = { version = "4" } color-eyre = { version = "0.6", default-features = false } -ril = { version = "0.10", default-features = false, features = [ - "png", - "resize", - "webp", -] } [target.'cfg(target_family = "wasm")'.dependencies] js-sys = "0.3" -ril = { version = "0.10", default-features = false } wasm-bindgen = "0.2" web-sys = { version = "0.3", features = ["ImageData"] } getrandom = { version = "0.2", features = ["js"] } diff --git a/catwalk/src/main.rs b/catwalk/src/main.rs index 97a70c13..7f8dbb0b 100644 --- a/catwalk/src/main.rs +++ b/catwalk/src/main.rs @@ -66,22 +66,11 @@ fn main() -> Result<()> { match args.output.extension() { None => return Err(eyre!("Output file type could not be determined")), Some(os_str) => match os_str.to_str() { - Some("png") => { - use ril::encodings::png::PngEncoder; - - PngEncoder::encode_static(&catwalk, &mut writebuf)?; - } - Some("webp") => { - use ril::encodings::webp::{WebPEncoderOptions, WebPStaticEncoder}; - - let opt = WebPEncoderOptions::new().with_lossless(true); - let meta = EncoderMetadata::::from(&catwalk).with_config(opt); - let mut encoder = WebPStaticEncoder::new(&mut writebuf, meta)?; - encoder.add_frame(&catwalk)?; - } + Some("png") => catwalk.encode(ImageFormat::Png, &mut writebuf)?, + Some("webp") => catwalk.encode(ImageFormat::WebP, &mut writebuf)?, _ => return Err(eyre!("Output file type not supported")), }, - } + }; let output = if args.directory.is_some() { let mut path = args.directory.clone().unwrap_or_default(); @@ -95,5 +84,7 @@ fn main() -> Result<()> { args.output }; - std::fs::write(output, writebuf.get_ref()).map_err(|e| eyre!("Failed to write image: {}", e)) + // std::fs::write(output, writebuf.get_ref()).map_err(|e| eyre!("Failed to write image: {}", e)) + catwalk.save_inferred(output)?; + Ok(()) }