diff --git a/Cargo.toml b/Cargo.toml index 05cd0fc..a46d0ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ readme = "README.md" license = "Apache-2.0" authors = ["trivernis "] description = "An image thumbnail creation library" -version = "0.1.0" +version = "0.2.0" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/lib.rs b/src/lib.rs index ab7ef9d..019fc78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,15 +42,16 @@ pub struct Thumbnail { impl Thumbnail { /// Writes the bytes of the image in a png format pub fn write_png(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(()) } /// Writes the bytes of the image in a jpeg format pub fn write_jpeg(self, writer: &mut W, compression: u8) -> ThumbResult<()> { - self.inner - .write_to(writer, ImageOutputFormat::Jpeg(compression))?; + let image = DynamicImage::ImageRgb8(self.inner.into_rgb8()); + image.write_to(writer, ImageOutputFormat::Jpeg(compression))?; Ok(()) }