exif: Show device maker more consitently
Also, don't call it camera because it can be a scanner etc as well
This commit is contained in:
parent
cbde386126
commit
4b9c91f8df
3 changed files with 38 additions and 6 deletions
|
|
@ -162,7 +162,25 @@ impl ImageMetadata {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn camera_model(&self) -> Option<String> {
|
||||
/// Combined maker and model info
|
||||
pub fn maker_model(&self) -> Option<String> {
|
||||
if let Some(mut model) = self.model() {
|
||||
if let Some(maker) = self.maker() {
|
||||
// This is to avoid doubling the maker name
|
||||
// Canon for example also puts "Canon" in the model as well
|
||||
// NIKON sometimes puts "NIKON" in model and "NIKON CORPORATION" in maker
|
||||
if model.split_whitespace().next() != maker.split_whitespace().next() {
|
||||
model = format!("{maker} {model}");
|
||||
}
|
||||
}
|
||||
|
||||
Some(model)
|
||||
} else {
|
||||
self.maker()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn model(&self) -> Option<String> {
|
||||
if let Self::Exif(exif) = self {
|
||||
if let Some(field) = exif.get_field(exif::Tag::Model, exif::In::PRIMARY) {
|
||||
if let exif::Value::Ascii(value) = &field.value {
|
||||
|
|
@ -176,6 +194,20 @@ impl ImageMetadata {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn maker(&self) -> Option<String> {
|
||||
if let Self::Exif(exif) = self {
|
||||
if let Some(field) = exif.get_field(exif::Tag::Make, exif::In::PRIMARY) {
|
||||
if let exif::Value::Ascii(value) = &field.value {
|
||||
if let Some(entry) = value.first() {
|
||||
return Some(String::from_utf8_lossy(entry).to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn gps_location(&self) -> Option<GPSLocation> {
|
||||
if let Self::Exif(exif) = self {
|
||||
if let (Some(latitude), Some(latitude_ref), Some(longitude), Some(longitude_ref)) = (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue