From 9307f2d49faa01cc5bcc63a3921f30e449c449aa Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 15 Jun 2020 00:33:50 +0200 Subject: [PATCH] rotate image pixels, prototype a function to get exif data --- src/blob.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/blob.rs b/src/blob.rs index c417dd129..2946f882e 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -14,6 +14,7 @@ use thiserror::Error; use crate::config::Config; use crate::constants::*; use crate::context::Context; +use crate::error::Error; use crate::events::Event; use crate::message; @@ -408,7 +409,13 @@ impl<'a> BlobObject<'a> { return Ok(()); } - let img = img.thumbnail(img_wh, img_wh); + let mut img = img.thumbnail(img_wh, img_wh); + match self.get_exif_orientation() { + Ok(90) => img = img.rotate90(), + Ok(180) => img = img.rotate180(), + Ok(270) => img = img.rotate270(), + _ => {} + } img.save(&blob_abs).map_err(|err| BlobError::WriteFailure { blobdir: context.get_blobdir().to_path_buf(), @@ -418,6 +425,10 @@ impl<'a> BlobObject<'a> { Ok(()) } + + pub fn get_exif_orientation(&self) -> Result { + Ok(0) + } } impl<'a> fmt::Display for BlobObject<'a> {