From a1f682e9cbedf9a67dbb2c413f10f52f0b78c59d Mon Sep 17 00:00:00 2001 From: Dustin Thomson Date: Sun, 10 Mar 2019 18:48:30 -0400 Subject: [PATCH] Added canonical_model to image and camera to allow software to get the non-localized model --- src/decoders/dng.rs | 6 ++++-- src/decoders/image.rs | 6 ++++++ src/decoders/mod.rs | 16 ++++++++++++++-- src/decoders/raf.rs | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/decoders/dng.rs b/src/decoders/dng.rs index 921dee70..02f63b90 100644 --- a/src/decoders/dng.rs +++ b/src/decoders/dng.rs @@ -63,9 +63,11 @@ impl<'a> Decoder for DngDecoder<'a> { Ok(RawImage { make: make, - model: model, + model: model.clone(), + canonical_model: model, clean_make: clean_make, - clean_model: clean_model, + clean_model: clean_model.clone(), + clean_canonical_model: clean_model, width: width, height: height, cpp: cpp, diff --git a/src/decoders/image.rs b/src/decoders/image.rs index 52abaaf4..e25e8a50 100644 --- a/src/decoders/image.rs +++ b/src/decoders/image.rs @@ -9,10 +9,14 @@ pub struct RawImage { pub make: String, /// camera model as encoded in the file pub model: String, + /// official camera model + pub canonical_model: String, /// make cleaned up to be consistent and short pub clean_make: String, /// model cleaned up to be consistent and short pub clean_model: String, + /// official model cleaned up to be consistent and short + pub clean_canonical_model: String, /// width of the full image pub width: usize, /// height of the full image @@ -94,8 +98,10 @@ impl RawImage { RawImage { make: camera.make.clone(), model: camera.model.clone(), + canonical_model: camera.canonical_model.clone(), clean_make: camera.clean_make.clone(), clean_model: camera.clean_model.clone(), + clean_canonical_model: camera.clean_canonical_model.clone(), width: width, height: height, cpp: 1, diff --git a/src/decoders/mod.rs b/src/decoders/mod.rs index 12b9f773..32bd49d1 100644 --- a/src/decoders/mod.rs +++ b/src/decoders/mod.rs @@ -97,9 +97,11 @@ impl Buffer { pub struct Camera { pub make: String, pub model: String, + pub canonical_model: String, pub mode: String, pub clean_make: String, pub clean_model: String, + pub clean_canonical_model: String, pub filesize: usize, pub raw_width: usize, pub raw_height: usize, @@ -126,10 +128,18 @@ impl Camera { for (name, val) in ct { match name.as_ref() { "make" => {self.make = val.as_str().unwrap().to_string().clone();}, - "model" => {self.model = val.as_str().unwrap().to_string().clone();}, + "model" => { + let model = val.as_str().unwrap().to_string(); + self.model = model.clone(); + self.canonical_model = model.clone(); + }, "mode" => {self.mode = val.as_str().unwrap().to_string().clone();}, "clean_make" => {self.clean_make = val.as_str().unwrap().to_string().clone();}, - "clean_model" => {self.clean_model = val.as_str().unwrap().to_string().clone();}, + "clean_model" => { + let model = val.as_str().unwrap().to_string(); + self.clean_model = model.clone(); + self.clean_canonical_model = model.clone(); + }, "whitepoint" => {let white = val.as_integer().unwrap() as u16; self.whitelevels = [white, white, white, white];}, "blackpoint" => {let black = val.as_integer().unwrap() as u16; self.blacklevels = [black, black, black, black];}, "blackareah" => { @@ -176,9 +186,11 @@ impl Camera { Camera { make: "".to_string(), model: "".to_string(), + canonical_model: "".to_string(), mode: "".to_string(), clean_make: "".to_string(), clean_model: "".to_string(), + clean_canonical_model: "".to_string(), filesize: 0, raw_width: 0, raw_height: 0, diff --git a/src/decoders/raf.rs b/src/decoders/raf.rs index 0fb132f0..7bb193b9 100644 --- a/src/decoders/raf.rs +++ b/src/decoders/raf.rs @@ -68,8 +68,10 @@ impl<'a> Decoder for RafDecoder<'a> { Ok(RawImage { make: camera.make.clone(), model: camera.model.clone(), + canonical_model: camera.canonical_model.clone(), clean_make: camera.clean_make.clone(), clean_model: camera.clean_model.clone(), + clean_canonical_model: camera.canonical_model.clone(), width: width, height: height, cpp: 1,