From 9c0d517dabd856761460bf1721a4a1e96e58fec7 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 13 Sep 2024 06:49:56 +0100 Subject: [PATCH] Add a function to convert from Orientation to Exif values --- src/orientation.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/orientation.rs b/src/orientation.rs index 37399e47c8..f2e2493b33 100644 --- a/src/orientation.rs +++ b/src/orientation.rs @@ -38,4 +38,17 @@ impl Orientation { } } + /// Converts into [Exif orientation](https://web.archive.org/web/20200412005226/https://www.impulseadventure.com/photo/exif-orientation.html) + pub fn to_exif(self) -> u8 { + match self { + Self::NoTransforms => 1, + Self::FlipHorizontal => 2, + Self::Rotate180 => 3, + Self::FlipVertical => 4, + Self::Rotate90FlipH => 5, + Self::Rotate90 => 6, + Self::Rotate270FlipH => 7, + Self::Rotate270 => 8, + } + } }