diff --git a/src/image.rs b/src/image.rs index 977da9e..dcbacfe 100644 --- a/src/image.rs +++ b/src/image.rs @@ -111,3 +111,15 @@ impl From for Error { Error::Io(error) } } + +impl Image { + pub fn load(path: &str) -> Result { + let file = std::fs::File::open(path)?; + F::read(&mut std::io::BufReader::new(file)) + } + + pub fn save(&self, path: &str) -> std::io::Result<()> { + let file = std::fs::File::create(path)?; + F::write(&mut std::io::BufWriter::new(file), self) + } +}