editing: Decide editable based on true mime type

Previously it was decided on the early unreliable mime type.

Fixes #449
This commit is contained in:
Sophie Herold 2025-02-19 11:46:32 +01:00
parent e3a58270b1
commit 1d40a28b54
4 changed files with 31 additions and 12 deletions

View file

@ -105,17 +105,28 @@ impl Metadata {
}
pub fn mime_type(&self) -> Option<String> {
self.file_info
.as_ref()
.and_then(|x| x.mime_type.as_ref())
.map(|x| x.to_string())
self.mime_type.clone()
}
/// Unreliable mime type
///
/// Before the image is successfully loaded, this mime type might be wrong
/// since it is not yet based on the more complex mime type detection used
/// by glyin.
pub fn unreliable_mime_type(&self) -> Option<String> {
self.mime_type().or_else(|| {
self.file_info
.as_ref()
.and_then(|x| x.mime_type.as_ref())
.map(|x| x.to_string())
})
}
pub fn format_name(&self) -> Option<String> {
self.image_info
.as_ref()
.and_then(|x| x.format_name.clone())
.or_else(|| self.mime_type())
.or_else(|| self.unreliable_mime_type())
}
pub fn alpha_channel(&self) -> Option<bool> {