From b827f9cc66ec98cb63e1f2a9ebf3f1d87289ffc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Fri, 20 Oct 2023 00:33:55 -0300 Subject: [PATCH] Enable thumbnail support for webp images (#1634) * Enable thumbnail support for webp images * Remove webp optional dep from sd-images crate --- Cargo.lock | Bin 235770 -> 235761 bytes crates/images/Cargo.toml | 1 - crates/images/src/consts.rs | 6 ++++-- packages/client/src/core.ts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index febede60c8c952bb1c42ba9525f3607ea7b42ee2..25dd576c769153cace05c175f285f264af54a677 100644 GIT binary patch delta 28 kcmeyhk?-S1zJ?aYElgJ{r}Nh^Nw@#3WZM3-l9^E+0KioX`2YX_ delta 28 kcmeykk?+?=zJ?aYElgJ{r$<#VDYw6`WZM3|l9@>!0K@JKH2?qr diff --git a/crates/images/Cargo.toml b/crates/images/Cargo.toml index dab8cb5ba..740917871 100644 --- a/crates/images/Cargo.toml +++ b/crates/images/Cargo.toml @@ -14,7 +14,6 @@ heif = ["dep:libheif-rs", "dep:libheif-sys"] [dependencies] image = "0.24.7" -webp = { version = "0.2.6", optional = true } thiserror = "1.0.49" resvg = "0.36.0" rspc = { workspace = true, optional = true } # error conversion diff --git a/crates/images/src/consts.rs b/crates/images/src/consts.rs index 5636a61e6..c98c00f15 100644 --- a/crates/images/src/consts.rs +++ b/crates/images/src/consts.rs @@ -11,9 +11,9 @@ pub const MAXIMUM_FILE_SIZE: u64 = MIB * 192; /// These are roughly all extensions supported by the `image` crate, as of `v0.24.7`. /// /// We only support images that have both good encoding and decoding support, without external C-based dependencies (e.g. `avif`) -pub const GENERIC_EXTENSIONS: [&str; 16] = [ +pub const GENERIC_EXTENSIONS: [&str; 17] = [ "bmp", "dib", "ff", "gif", "ico", "jpg", "jpeg", "png", "pnm", "qoi", "tga", "icb", "vda", - "vst", "tiff", "tif", + "vst", "tiff", "tif", "webp", ]; pub const SVG_EXTENSIONS: [&str; 2] = ["svg", "svgz"]; pub const PDF_EXTENSIONS: [&str; 1] = ["pdf"]; @@ -67,6 +67,7 @@ pub enum ConvertableExtension { Svg, Svgz, Pdf, + Webp, } impl Display for ConvertableExtension { @@ -107,6 +108,7 @@ impl TryFrom for ConvertableExtension { "svg" => Ok(Self::Svg), "svgz" => Ok(Self::Svgz), "pdf" => Ok(Self::Pdf), + "webp" => Ok(Self::Webp), _ => Err(crate::Error::Unsupported), } } diff --git a/packages/client/src/core.ts b/packages/client/src/core.ts index 536ad1761..60dbeff54 100644 --- a/packages/client/src/core.ts +++ b/packages/client/src/core.ts @@ -140,7 +140,7 @@ export type Composite = "Unknown" | "False" | "General" | "Live" export type ConvertImageArgs = { location_id: number; file_path_id: number; delete_src: boolean; desired_extension: ConvertableExtension; quality_percentage: number | null } -export type ConvertableExtension = "bmp" | "dib" | "ff" | "gif" | "ico" | "jpg" | "jpeg" | "png" | "pnm" | "qoi" | "tga" | "icb" | "vda" | "vst" | "tiff" | "tif" | "heif" | "heifs" | "heic" | "heics" | "avif" | "avci" | "avcs" | "svg" | "svgz" | "pdf" +export type ConvertableExtension = "bmp" | "dib" | "ff" | "gif" | "ico" | "jpg" | "jpeg" | "png" | "pnm" | "qoi" | "tga" | "icb" | "vda" | "vst" | "tiff" | "tif" | "heif" | "heifs" | "heic" | "heics" | "avif" | "avci" | "avcs" | "svg" | "svgz" | "pdf" | "webp" export type CreateEphemeralFolderArgs = { path: string; name: string | null }