From bae0a89920859c657cb971910083acba7b1a7fa8 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Mon, 27 May 2024 20:43:56 +0200 Subject: [PATCH] exif: Always return an orientation, default to Id --- Cargo.toml | 4 ++-- gufo-exif/src/high_level.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d800653..2f569ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,10 @@ cast_possible_truncation = "forbid" cast_possible_wrap = "forbid" [workspace.dependencies] -gufo-exif = { path = "gufo-exif" } gufo-common = { path = "gufo-common" } +gufo-exif = { path = "gufo-exif" } gufo-jpeg = { path = "gufo-jpeg" } +gufo-xmp = { path = "gufo-xmp" } once_cell = "1.19.0" paste = "1.0.15" serde = { version = "1.0.202", features = ["derive"] } -gufo-xmp = { path = "gufo-xmp" } diff --git a/gufo-exif/src/high_level.rs b/gufo-exif/src/high_level.rs index 72ceecd..28b6758 100644 --- a/gufo-exif/src/high_level.rs +++ b/gufo-exif/src/high_level.rs @@ -25,17 +25,17 @@ impl Exif { /// /// Rotation and mirroring that have to be applied to show the image /// correctly - pub fn orientation(&self) -> Option { - let num = self - .decoder + pub fn orientation(&self) -> orientation::Orientation { + self.decoder .borrow_mut() .lookup_short(TagIfd::new( field::Orientation::TAG, field::Orientation::IFD, )) - .ok()??; - - orientation::Orientation::try_from(num).ok() + .ok() + .flatten() + .and_then(|x| orientation::Orientation::try_from(x).ok()) + .unwrap_or(orientation::Orientation::Id) } /// Camera manifacturer