Skip to content

Commit 0da0895

Browse files
authored
Use Into for ColorType to ExtendedColorType (#2885)
1 parent 25d1d5f commit 0da0895

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

components/imageproc/src/processor.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use libs::image::codecs::avif::AvifEncoder;
1010
use libs::image::codecs::jpeg::JpegEncoder;
1111
use libs::image::imageops::FilterType;
1212
use libs::image::GenericImageView;
13-
use libs::image::{EncodableLayout, ExtendedColorType, ImageEncoder, ImageFormat};
13+
use libs::image::{EncodableLayout, ImageEncoder, ImageFormat};
1414
use libs::rayon::prelude::*;
1515
use libs::{image, webp};
1616
use serde::{Deserialize, Serialize};
@@ -75,25 +75,12 @@ impl ImageOp {
7575
}
7676
Format::Avif { quality, speed } => {
7777
let mut avif: Vec<u8> = Vec::new();
78-
let color_type = match img.color() {
79-
image::ColorType::L8 => Ok(ExtendedColorType::L8),
80-
image::ColorType::La8 => Ok(ExtendedColorType::La8),
81-
image::ColorType::Rgb8 => Ok(ExtendedColorType::Rgb8),
82-
image::ColorType::Rgba8 => Ok(ExtendedColorType::Rgba8),
83-
image::ColorType::L16 => Ok(ExtendedColorType::L16),
84-
image::ColorType::La16 => Ok(ExtendedColorType::La16),
85-
image::ColorType::Rgb16 => Ok(ExtendedColorType::Rgb16),
86-
image::ColorType::Rgba16 => Ok(ExtendedColorType::Rgba16),
87-
image::ColorType::Rgb32F => Ok(ExtendedColorType::Rgb32F),
88-
image::ColorType::Rgba32F => Ok(ExtendedColorType::Rgba32F),
89-
c => Err(anyhow!("Unknown image color type '{:?}' for AVIF", c)),
90-
}?;
9178
let encoder = AvifEncoder::new_with_speed_quality(&mut avif, speed, quality);
9279
encoder.write_image(
9380
&img.as_bytes(),
9481
img.dimensions().0,
9582
img.dimensions().1,
96-
color_type,
83+
img.color().into(),
9784
)?;
9885
buffered_f.write_all(&avif.as_bytes())?;
9986
}

0 commit comments

Comments
 (0)