Fix the compatibility issues with kmeans_colors
- ID
88eaf60- date
2024-05-12 09:16:19+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
fff3ed8- message
Fix the compatibility issues with kmeans_colors I'm following the instructions from the changelog: bumping `palette` to `0.7`, and switching from `from_raw_slice` to `from_component_slice`.- changed files
3 files, 8 additions, 59 deletions
Changed files
Cargo.lock (14906) → Cargo.lock (13655)
diff --git a/Cargo.lock b/Cargo.lock
index 0d77a44..e128919 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -153,7 +153,7 @@ dependencies = [
"clap",
"image",
"kmeans_colors",
- "palette 0.6.1",
+ "palette",
]
[[package]]
@@ -163,15 +163,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"
[[package]]
-name = "find-crate"
-version = "0.6.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2"
-dependencies = [
- "toml",
-]
-
-[[package]]
name = "flate2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -241,7 +232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9a15ffb2811dc35dd7efefc227cf208a68eb8abc76be325d6319eba37747894"
dependencies = [
"num-traits",
- "palette 0.7.6",
+ "palette",
"rand",
"rand_chacha",
]
@@ -305,36 +296,13 @@ checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "palette"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f9cd68f7112581033f157e56c77ac4a5538ec5836a2e39284e65bd7d7275e49"
-dependencies = [
- "approx",
- "num-traits",
- "palette_derive 0.6.1",
-]
-
-[[package]]
-name = "palette"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6"
dependencies = [
"approx",
"fast-srgb8",
- "palette_derive 0.7.6",
-]
-
-[[package]]
-name = "palette_derive"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05eedf46a8e7c27f74af0c9cfcdb004ceca158cb1b918c6f68f8d7a549b3e427"
-dependencies = [
- "find-crate",
- "proc-macro2",
- "quote",
- "syn 1.0.102",
+ "palette_derive",
]
[[package]]
@@ -346,7 +314,7 @@ dependencies = [
"by_address",
"proc-macro2",
"quote",
- "syn 2.0.63",
+ "syn",
]
[[package]]
@@ -462,17 +430,6 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
-version = "1.0.102"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
-[[package]]
-name = "syn"
version = "2.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704"
@@ -509,15 +466,6 @@ dependencies = [
]
[[package]]
-name = "toml"
-version = "0.5.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
-dependencies = [
- "serde",
-]
-
-[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
Cargo.toml (417) → Cargo.toml (417)
diff --git a/Cargo.toml b/Cargo.toml
index bd95d76..3534433 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,6 +18,6 @@ features = ["jpeg", "png", "gif", "tiff"]
default-features = false
[dependencies.palette]
-version = "0.6"
+version = "0.7"
default-features = false
features = ["std"]
src/main.rs (8395) → src/main.rs (8441)
diff --git a/src/main.rs b/src/main.rs
index 867c999..62b8d32 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,8 @@
extern crate clap;
use kmeans_colors::get_kmeans_hamerly;
-use palette::{FromColor, IntoColor, Lab, Pixel, Srgb, Srgba};
+use palette::cast::from_component_slice;
+use palette::{FromColor, IntoColor, Lab, Srgb, Srgba};
mod cli;
mod get_bytes;
@@ -31,7 +32,7 @@ fn main() {
// This is based on code from the kmeans-colors binary, but with a bunch of
// the options stripped out.
// See https://github.com/okaneco/kmeans-colors/blob/0.5.0/src/bin/kmeans_colors/app.rs
- let lab: Vec<Lab> = Srgba::from_raw_slice(&img_bytes)
+ let lab: Vec<Lab> = from_component_slice::<Srgba<u8>>(&img_bytes)
.iter()
.map(|x| x.into_format::<_, f32>().into_color())
.collect();