Add support for WebP images
- ID
c4be0c8- date
2024-05-12 10:03:38+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
94aa7dc- message
Add support for WebP images- changed files
5 files, 46 additions, 4 deletions
Changed files
Cargo.lock (15862) → Cargo.lock (16805)
diff --git a/Cargo.lock b/Cargo.lock
index dc94ea9..5d170eb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -123,6 +123,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
+name = "byteorder-lite"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
+
+[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -190,7 +196,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]]
name = "dominant_colours"
-version = "1.1.8"
+version = "1.1.9"
dependencies = [
"assert_cmd",
"clap",
@@ -246,6 +252,7 @@ dependencies = [
"byteorder",
"color_quant",
"gif",
+ "image-webp",
"num-traits",
"png",
"tiff",
@@ -254,6 +261,16 @@ dependencies = [
]
[[package]]
+name = "image-webp"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d730b085583c4d789dfd07fdcf185be59501666a90c97c40162b37e4fdad272d"
+dependencies = [
+ "byteorder-lite",
+ "thiserror",
+]
+
+[[package]]
name = "is_terminal_polyfill"
version = "1.70.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -459,6 +476,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b"
[[package]]
+name = "thiserror"
+version = "1.0.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "tiff"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
Cargo.toml (416) → Cargo.toml (424)
diff --git a/Cargo.toml b/Cargo.toml
index 1ff1125..f7f467e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ default-features = false
[dependencies.image]
version = "0.25"
-features = ["jpeg", "png", "gif", "tiff"]
+features = ["jpeg", "png", "gif", "tiff", "webp"]
default-features = false
[dependencies.palette]
src/get_image_colors.rs (5109) → src/get_image_colors.rs (5212)
diff --git a/src/get_image_colors.rs b/src/get_image_colors.rs
index 42ff9e9..c69ac00 100644
--- a/src/get_image_colors.rs
+++ b/src/get_image_colors.rs
@@ -143,4 +143,9 @@ mod test {
fn it_gets_colors_for_mri_fruit() {
get_image_colors("./src/tests/garlic.gif");
}
+
+ #[test]
+ fn get_colors_for_webp() {
+ get_image_colors("./src/tests/purple.webp");
+ }
}
src/main.rs (7438) → src/main.rs (7440)
diff --git a/src/main.rs b/src/main.rs
index 8418536..ff24d85 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -201,11 +201,11 @@ mod tests {
#[test]
fn it_fails_if_you_pass_an_unsupported_image_format() {
- let output = get_failure(&["./src/tests/purple.webp"]);
+ let output = get_failure(&["./src/tests/orange.heic"]);
assert_eq!(output.exit_code, 1);
assert_eq!(output.stdout, "");
- assert_eq!(output.stderr, "The image format WebP is not supported\n");
+ assert_eq!(output.stderr, "The image format could not be determined\n");
}
#[test]
src/tests/orange.heic (0) → src/tests/orange.heic (495)
diff --git a/src/tests/orange.heic b/src/tests/orange.heic
new file mode 100644
index 0000000..40e6a87
Binary files /dev/null and b/src/tests/orange.heic differ