|
|
@ -42,15 +42,16 @@ pub struct Thumbnail {
|
|
|
|
impl Thumbnail {
|
|
|
|
impl Thumbnail {
|
|
|
|
/// Writes the bytes of the image in a png format
|
|
|
|
/// Writes the bytes of the image in a png format
|
|
|
|
pub fn write_png<W: Write>(self, writer: &mut W) -> ThumbResult<()> {
|
|
|
|
pub fn write_png<W: Write>(self, writer: &mut W) -> ThumbResult<()> {
|
|
|
|
self.inner.write_to(writer, ImageOutputFormat::Png)?;
|
|
|
|
let image = DynamicImage::ImageRgba8(self.inner.into_rgba8());
|
|
|
|
|
|
|
|
image.write_to(writer, ImageOutputFormat::Png)?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Writes the bytes of the image in a jpeg format
|
|
|
|
/// Writes the bytes of the image in a jpeg format
|
|
|
|
pub fn write_jpeg<W: Write>(self, writer: &mut W, compression: u8) -> ThumbResult<()> {
|
|
|
|
pub fn write_jpeg<W: Write>(self, writer: &mut W, compression: u8) -> ThumbResult<()> {
|
|
|
|
self.inner
|
|
|
|
let image = DynamicImage::ImageRgb8(self.inner.into_rgb8());
|
|
|
|
.write_to(writer, ImageOutputFormat::Jpeg(compression))?;
|
|
|
|
image.write_to(writer, ImageOutputFormat::Jpeg(compression))?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|