diff --git a/src/main.rs b/src/main.rs index 7395a19..7b9f978 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; use eyre::{Context, ContextCompat, bail, ensure, eyre}; use image::{ - DynamicImage, GrayAlphaImage, ImageReader, + DynamicImage, GrayAlphaImage, ImageFormat, ImageReader, imageops::{flip_vertical_in_place, overlay}, }; use nix::ioctl_write_ptr; @@ -15,6 +15,8 @@ use std::{ #[derive(Parser)] struct Opt { /// Path to the image-blob. "-" means stdin. + /// + /// When reading from stdin, format must be PNG. pub path: PathBuf, /// Stamp an image onto the final image. "::" @@ -70,7 +72,9 @@ fn load_wallpaper(path: &Path) -> eyre::Result { eprintln!("Reading image from stdin"); let mut buf = vec![]; stdin().read_to_end(&mut buf)?; - ImageReader::new(Cursor::new(buf)).decode()? + let mut reader = ImageReader::new(Cursor::new(buf)); + reader.set_format(ImageFormat::Png); + reader.decode()? } else { eprintln!("Opening image at {path:?}"); ImageReader::open(path)?.decode()?