From afc9ecbd517a40088547be96b854aaf523cfc85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 12 Sep 2026 10:42:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=20WebP=20=E6=BA=90=E5=9B=BE?= =?UTF-8?q?=E8=BD=AC=E7=A0=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 验证 WebP 输入可转换为 PNG 上传格式 --- .../commands/separation/workflow/extract.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/extract.rs b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/extract.rs index 08d8cffc4..204d9141d 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/extract.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/ui_editor/commands/separation/workflow/extract.rs @@ -154,6 +154,18 @@ mod tests { let png = normalize_source_image_to_png(jpeg).expect("convert jpeg"); assert_eq!(&png[..8], b"\x89PNG\r\n\x1a\n"); } + + #[test] + fn converts_webp_source_to_png() { + let image = DynamicImage::ImageRgb8(RgbImage::from_pixel(2, 2, Rgb([0, 128, 255]))); + let mut webp = Vec::new(); + image + .write_to(&mut Cursor::new(&mut webp), ImageFormat::WebP) + .expect("encode webp"); + + let png = normalize_source_image_to_png(webp).expect("convert webp"); + assert_eq!(&png[..8], b"\x89PNG\r\n\x1a\n"); + } } pub(super) async fn write_processed_image(