Change output bit depth to fixed size rgb8 (with alpha for png)

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent a18bafb39e
commit 8e2a37c3eb
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -4,7 +4,7 @@ readme = "README.md"
license = "Apache-2.0" license = "Apache-2.0"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
description = "An image thumbnail creation library" description = "An image thumbnail creation library"
version = "0.1.0" version = "0.2.0"
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -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(())
} }

Loading…
Cancel
Save