From 017be62f244f1705ad1c557df2d754b4009036d7 Mon Sep 17 00:00:00 2001 From: Gigas002 <24297712+Gigas002@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:06:32 +0900 Subject: [PATCH] feat: Add support for webp (#98) Signed-off-by: Shinyzenith --------- Signed-off-by: Shinyzenith Co-authored-by: Shinyzenith --- docs/wayshot.1.scd | 1 + wayshot/Cargo.toml | 1 + wayshot/src/utils.rs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/docs/wayshot.1.scd b/docs/wayshot.1.scd index 1ab5762f..47a9a8fe 100644 --- a/docs/wayshot.1.scd +++ b/docs/wayshot.1.scd @@ -33,6 +33,7 @@ Wayshot - Screenshot tool for compositors implementing zwlr_screencopy_v1 such a - png (Default encoder) - ppm - qoi + - webp *-f*, *--file* Set a custom file path. The default path is `./{current_unix_timestamp}-wayshot.{encoder}` diff --git a/wayshot/Cargo.toml b/wayshot/Cargo.toml index 3a111f26..2835b246 100644 --- a/wayshot/Cargo.toml +++ b/wayshot/Cargo.toml @@ -28,6 +28,7 @@ image = { version = "0.24", default-features = false, features = [ "png", "pnm", "qoi", + "webp-encoder", ] } dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } diff --git a/wayshot/src/utils.rs b/wayshot/src/utils.rs index 158f997f..1f8bf8b4 100644 --- a/wayshot/src/utils.rs +++ b/wayshot/src/utils.rs @@ -58,6 +58,8 @@ pub enum EncodingFormat { Ppm, /// Qut encoder. Qoi, + /// WebP encoder, + Webp, } impl Default for EncodingFormat { @@ -73,6 +75,7 @@ impl From for image::ImageOutputFormat { EncodingFormat::Png => image::ImageFormat::Png.into(), EncodingFormat::Ppm => image::ImageFormat::Pnm.into(), EncodingFormat::Qoi => image::ImageFormat::Qoi.into(), + EncodingFormat::Webp => image::ImageFormat::WebP.into(), } } } @@ -111,6 +114,7 @@ impl From for &str { EncodingFormat::Png => "png", EncodingFormat::Ppm => "ppm", EncodingFormat::Qoi => "qoi", + EncodingFormat::Webp => "webp", } } }