decoder: Use glycin 1.0

This commit is contained in:
Sophie Herold 2023-12-25 21:34:18 +01:00
parent 0e490f38ad
commit f14cb540eb
9 changed files with 124 additions and 99 deletions

View file

@ -57,10 +57,10 @@ impl Glycin {
let image = image_request.request().await?;
if let Some(exif_raw) = image.info().exif.clone().into() {
if let Some(exif_raw) = image.info().details.exif.clone() {
let mut metadata = Metadata::default();
metadata.set_exif_bytes(exif_raw);
metadata.set_transformations_applied(image.info().transformations_applied);
metadata.set_transformations_applied(image.info().details.transformations_applied);
updater.send(DecoderUpdate::Metadata(metadata));
}

View file

@ -78,11 +78,8 @@ impl Svg {
let image = image_request.request().await?;
let dimensions = if let Some(string) = image.info().dimensions_text.as_ref() {
ImageDimensionDetails::Svg(
string.to_string(),
image.info().dimensions_inch.clone().into(),
)
let dimensions = if let Some(string) = image.info().details.dimensions_text.as_ref() {
ImageDimensionDetails::Svg(string.to_string(), image.info().details.dimensions_inch)
} else {
ImageDimensionDetails::None
};

View file

@ -146,7 +146,7 @@ impl Decoder {
if mime_type.split('+').next() == Some("image/svg") {
update_sender.send(DecoderUpdate::Format(ImageFormat::new(
mime_type,
"SVG".into(),
Some("SVG".into()),
)));
return FormatDecoder::Svg(Svg::new(file, update_sender, tiles));
}

View file

@ -62,7 +62,7 @@ mod widgets;
mod window;
mod deps {
pub use gtk::{cairo, gdk, gdk_pixbuf, gio, glib, graphene, gsk};
pub use gtk::{cairo, gdk, gio, glib, graphene, gsk};
}
use application::LpApplication;

View file

@ -15,14 +15,16 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later
use crate::util::gettext::*;
#[derive(Clone, Debug)]
pub struct ImageFormat {
mime_type: glycin::MimeType,
name: String,
name: Option<String>,
}
impl ImageFormat {
pub fn new(mime_type: glycin::MimeType, name: String) -> Self {
pub fn new(mime_type: glycin::MimeType, name: Option<String>) -> Self {
Self { mime_type, name }
}
@ -40,6 +42,10 @@ impl ImageFormat {
impl std::fmt::Display for ImageFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{}", self.name)
write!(
f,
"{}",
self.name.clone().unwrap_or_else(|| gettext("Unknown"))
)
}
}

View file

@ -74,7 +74,7 @@ impl GPSCoord {
}
fn position_exif(position: &[exif::Rational]) -> Option<(f64, Option<f64>, Option<f64>)> {
let (deg, mut min, mut sec) = (position.get(0)?, position.get(1), position.get(2));
let (deg, mut min, mut sec) = (position.first()?, position.get(1), position.get(2));
if let (Some(min_), Some(sec_)) = (min, sec) {
if min_.denom > 1 && sec_.num == 0 {