metadata: Move file info and format to metadata

This commit is contained in:
Sophie Herold 2023-12-04 12:52:40 +01:00
parent c36e7f4eb6
commit c0f435386d
16 changed files with 327 additions and 339 deletions

View file

@ -19,7 +19,7 @@
use super::*;
use crate::decoder::tiling::{self, FrameBufferExt};
use crate::deps::*;
use crate::image_metadata::ImageMetadata;
use crate::metadata::{ImageFormat, Metadata};
use arc_swap::ArcSwap;
use gtk::prelude::*;
@ -62,8 +62,9 @@ impl Glycin {
let image = image_request.request().await?;
if let Some(exif_raw) = image.info().exif.clone().into() {
let mut metadata = ImageMetadata::from_exif_bytes(exif_raw);
metadata.heif_transform = image.info().transformations_applied;
let mut metadata = Metadata::default();
metadata.set_exif_bytes(exif_raw);
metadata.set_transformations_applied(image.info().transformations_applied);
updater.send(DecoderUpdate::Metadata(metadata));
}

View file

@ -23,35 +23,6 @@ pub use svg::{Svg, RSVG_MAX_SIZE};
use super::{DecoderUpdate, UpdateSender};
#[derive(Clone, Debug)]
pub struct ImageFormat {
mime_type: glycin::MimeType,
name: String,
}
impl ImageFormat {
pub fn new(mime_type: glycin::MimeType, name: String) -> Self {
Self { mime_type, name }
}
pub fn is_svg(&self) -> bool {
matches!(
self.mime_type.as_str(),
"image/svg+xml" | "image/svg+xml-compressed"
)
}
pub fn is_potentially_transparent(&self) -> bool {
!matches!(self.mime_type.as_str(), "image/bmp" | "image/jpeg")
}
}
impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{}", self.name)
}
}
#[derive(Clone, Debug, Default)]
pub enum ImageDimensionDetails {
Svg(String),

View file

@ -20,6 +20,7 @@ use super::*;
use crate::decoder::tiling::{self, FrameBufferExt};
use crate::decoder::TileRequest;
use crate::deps::*;
use crate::metadata::ImageFormat;
use anyhow::Context;
use arc_swap::ArcSwap;