Skip to content

Commit

Permalink
Merge 21a7ebf into 5ffa722
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored Jun 5, 2023
2 parents 5ffa722 + 21a7ebf commit 469d0e9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/turbopack-image/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use anyhow::{bail, Context, Result};
use base64::{display::Base64Display, engine::general_purpose::STANDARD};
use image::{
codecs::{
bmp::BmpEncoder,
ico::IcoEncoder,
jpeg::JpegEncoder,
png::{CompressionType, PngEncoder},
},
Expand Down Expand Up @@ -190,6 +192,25 @@ fn encode_image(image: DynamicImage, format: ImageFormat, quality: u8) -> Result
)?;
(buf, mime::IMAGE_JPEG)
}
ImageFormat::Ico => {
IcoEncoder::new(&mut buf).write_image(
image.as_bytes(),
width,
height,
image.color(),
)?;
// mime does not support typed IMAGE_X_ICO yet
(buf, Mime::from_str("image/x-icon")?)
}
ImageFormat::Bmp => {
BmpEncoder::new(&mut buf).write_image(
image.as_bytes(),
width,
height,
image.color(),
)?;
(buf, mime::IMAGE_BMP)
}
#[cfg(feature = "webp")]
ImageFormat::WebP => {
use image::codecs::webp::{WebPEncoder, WebPQuality};
Expand Down

0 comments on commit 469d0e9

Please sign in to comment.