From c2f7a80d1429eb5adde4128be8e0df98689f7200 Mon Sep 17 00:00:00 2001 From: OJ Kwon <1210596+kwonoj@users.noreply.github.com> Date: Mon, 5 Jun 2023 10:26:34 -0700 Subject: [PATCH] fix(turbopack-image): fix build error (#5207) ### Description enabling webp never actually able to build. --- crates/turbopack-image/Cargo.toml | 1 + crates/turbopack-image/src/process/mod.rs | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/turbopack-image/Cargo.toml b/crates/turbopack-image/Cargo.toml index b0f840bb9c6aa..a55cba16aaca3 100644 --- a/crates/turbopack-image/Cargo.toml +++ b/crates/turbopack-image/Cargo.toml @@ -10,6 +10,7 @@ autobenches = false bench = false [features] + # [NOTE]: Before enable this, ensure this can build all of the target platforms we support. avif = ["image/avif-decoder", "image/avif-encoder"] webp = ["image/webp", "image/webp-encoder"] diff --git a/crates/turbopack-image/src/process/mod.rs b/crates/turbopack-image/src/process/mod.rs index 8747bc8b3556d..0fd4798b669fe 100644 --- a/crates/turbopack-image/src/process/mod.rs +++ b/crates/turbopack-image/src/process/mod.rs @@ -192,14 +192,13 @@ fn encode_image(image: DynamicImage, format: ImageFormat, quality: u8) -> Result } #[cfg(feature = "webp")] ImageFormat::WebP => { - use image::webp::{WebPEncoder, WebPQuality}; - WebPEncoder::new_with_quality(&mut buf, WebPQuality::lossy(options.quality)) - .write_image( - small_image.as_bytes(), - blur_width, - blur_height, - small_image.color(), - )?; + use image::codecs::webp::{WebPEncoder, WebPQuality}; + WebPEncoder::new_with_quality(&mut buf, WebPQuality::lossy(quality)).write_image( + image.as_bytes(), + width, + height, + image.color(), + )?; (buf, Mime::from_str("image/webp")?) } #[cfg(feature = "avif")]