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
|
|
@ -245,15 +245,15 @@
|
|||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Camera</property>
|
||||
<property name="title" translatable="yes">Maker, Model</property>
|
||||
<binding name="subtitle">
|
||||
<lookup name="camera-model">
|
||||
<lookup name="maker-model">
|
||||
<lookup name="metadata">LpPropertiesView</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
<binding name="visible">
|
||||
<closure type="gboolean" function="has_content">
|
||||
<lookup name="camera-model">
|
||||
<lookup name="maker-model">
|
||||
<lookup name="metadata">LpPropertiesView</lookup>
|
||||
</lookup>
|
||||
</closure>
|
||||
|
|
|
|||
|
|
@ -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)) = (
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ mod imp {
|
|||
"exposure-time",
|
||||
"iso",
|
||||
"focal-length",
|
||||
"camera-model",
|
||||
"maker-model",
|
||||
]
|
||||
.iter()
|
||||
.map(|name| glib::ParamSpecString::builder(name).read_only().build())
|
||||
|
|
@ -99,7 +99,7 @@ mod imp {
|
|||
"exposure-time" => metadata.exposure_time().to_value(),
|
||||
"iso" => metadata.iso().to_value(),
|
||||
"focal-length" => metadata.focal_length().to_value(),
|
||||
"camera-model" => metadata.camera_model().to_value(),
|
||||
"maker-model" => metadata.maker_model().to_value(),
|
||||
name => unimplemented!("property {name}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue