Update to glycin 2.0 alpha.7
This commit is contained in:
parent
1b0b68c773
commit
b3d972c5c3
8 changed files with 62 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2023-2024 Sophie Herold
|
||||
// Copyright (c) 2023-2025 Sophie Herold
|
||||
// Copyright (c) 2023 Automeris naranja
|
||||
// Copyright (c) 2023 Christopher Davis
|
||||
// Copyright (c) 2024 Andre Klapper
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ impl Glycin {
|
|||
log::trace!("Image info received");
|
||||
|
||||
let mut metadata: Metadata = Metadata::default();
|
||||
metadata.set_image_info(image.info().clone());
|
||||
metadata.set_image_info(image.details().clone());
|
||||
metadata.set_mime_type(image.mime_type().to_string());
|
||||
updater.send(DecoderUpdate::Metadata(Box::new(metadata)));
|
||||
|
||||
let dimensions = (image.info().width, image.info().height);
|
||||
let dimensions = (image.details().width(), image.details().height());
|
||||
tiles.set_original_dimensions(dimensions);
|
||||
|
||||
let frame = image.next_frame().await?;
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@ impl Svg {
|
|||
let image = loader.load().await?;
|
||||
|
||||
let mut metadata: Metadata = Metadata::default();
|
||||
metadata.set_image_info(image.info().clone());
|
||||
metadata.set_image_info(image.details().clone());
|
||||
metadata.set_mime_type(image.mime_type().to_string());
|
||||
updater.send(DecoderUpdate::Metadata(Box::new(metadata)));
|
||||
|
||||
tiles.set_original_dimensions((image.info().width, image.info().height));
|
||||
tiles.set_original_dimensions((image.details().width(), image.details().height()));
|
||||
|
||||
let mut is_first_frame = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl Queue {
|
|||
async fn apply(&self, image: LpImage) -> anyhow::Result<()> {
|
||||
let file = image.file().unwrap();
|
||||
#[allow(unused_mut)]
|
||||
let editor = glycin::Editor::new(file.clone());
|
||||
let editor = glycin::Editor::new(file.clone()).edit().await?;
|
||||
|
||||
let mut list = Vec::new();
|
||||
self.operations.rcu(|current_operations| {
|
||||
|
|
@ -69,7 +69,7 @@ impl Queue {
|
|||
});
|
||||
|
||||
let operations = Operations::new(list);
|
||||
let edit_instruction = editor.apply_sparse(operations).await?;
|
||||
let edit_instruction = editor.apply_sparse(&operations).await?;
|
||||
|
||||
if edit_instruction.apply_to(file).await? == EditOutcome::Unchanged {
|
||||
log::warn!("Writing new files is not supported yet");
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use std::str::FromStr;
|
|||
use chrono::prelude::*;
|
||||
pub use file::FileInfo;
|
||||
use glib::TimeZone;
|
||||
use glycin::{Frame, FrameDetails, ImageInfo, MemoryFormat};
|
||||
use glycin::{Frame, FrameDetails, ImageDetails, MemoryFormat};
|
||||
use gufo::common::datetime::DateTime;
|
||||
use gufo::common::orientation::Orientation;
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ pub struct Metadata {
|
|||
mime_type: Option<String>,
|
||||
metadata: gufo::Metadata,
|
||||
file_info: Option<FileInfo>,
|
||||
image_info: Option<glycin::ImageInfo>,
|
||||
image_info: Option<glycin::ImageDetails>,
|
||||
frame_info: Option<FrameDetails>,
|
||||
memory_format: Option<MemoryFormat>,
|
||||
}
|
||||
|
|
@ -60,11 +60,19 @@ impl Metadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_image_info(&mut self, image_info: ImageInfo) {
|
||||
if let Some(exif_raw) = image_info.exif.as_ref().and_then(|x| x.get_full().ok()) {
|
||||
pub fn set_image_info(&mut self, image_info: ImageDetails) {
|
||||
if let Some(exif_raw) = image_info
|
||||
.metadata_exif()
|
||||
.as_ref()
|
||||
.and_then(|x| x.get_full().ok())
|
||||
{
|
||||
self.set_exif_bytes(exif_raw);
|
||||
}
|
||||
if let Some(exif_xmp) = image_info.xmp.as_ref().and_then(|x| x.get_full().ok()) {
|
||||
if let Some(exif_xmp) = image_info
|
||||
.metadata_xmp()
|
||||
.as_ref()
|
||||
.and_then(|x| x.get_full().ok())
|
||||
{
|
||||
self.set_xmp_bytes(exif_xmp);
|
||||
}
|
||||
self.image_info = Some(image_info);
|
||||
|
|
@ -125,20 +133,22 @@ impl Metadata {
|
|||
pub fn format_name(&self) -> Option<String> {
|
||||
self.image_info
|
||||
.as_ref()
|
||||
.and_then(|x| x.format_name.clone())
|
||||
.and_then(|x| x.info_format_name().map(|x| x.to_string()))
|
||||
.or_else(|| self.unreliable_mime_type())
|
||||
}
|
||||
|
||||
pub fn alpha_channel(&self) -> Option<bool> {
|
||||
self.frame_info.as_ref().and_then(|x| x.alpha_channel)
|
||||
self.frame_info
|
||||
.as_ref()
|
||||
.and_then(|x| x.info_alpha_channel())
|
||||
}
|
||||
|
||||
pub fn grayscale(&self) -> Option<bool> {
|
||||
self.frame_info.as_ref().and_then(|x| x.grayscale)
|
||||
self.frame_info.as_ref().and_then(|x| x.info_grayscale())
|
||||
}
|
||||
|
||||
pub fn bit_depth(&self) -> Option<u8> {
|
||||
self.frame_info.as_ref().and_then(|x| x.bit_depth)
|
||||
self.frame_info.as_ref().and_then(|x| x.info_bit_depth())
|
||||
}
|
||||
|
||||
pub fn is_svg(&self) -> bool {
|
||||
|
|
@ -155,7 +165,7 @@ impl Metadata {
|
|||
pub fn transformations_applied(&self) -> bool {
|
||||
self.image_info
|
||||
.as_ref()
|
||||
.map(|x| x.transformations_applied)
|
||||
.map(|x| x.transformation_ignore_exif())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
|
|
@ -169,13 +179,13 @@ impl Metadata {
|
|||
}
|
||||
|
||||
pub fn dimensions_inch(&self) -> Option<(f64, f64)> {
|
||||
self.image_info.as_ref().and_then(|x| x.dimensions_inch)
|
||||
self.image_info.as_ref().and_then(|x| x.dimensions_inch())
|
||||
}
|
||||
|
||||
pub fn dimensions_text(&self) -> Option<String> {
|
||||
self.image_info
|
||||
.as_ref()
|
||||
.and_then(|x| x.dimensions_text.clone())
|
||||
.and_then(|x| x.info_dimensions_text().map(|x| x.to_string()))
|
||||
}
|
||||
|
||||
pub fn file_name(&self) -> Option<String> {
|
||||
|
|
|
|||
|
|
@ -349,7 +349,10 @@ mod imp {
|
|||
|
||||
if let Some(operations) = obj.operations() {
|
||||
log::debug!("Computing edited image.");
|
||||
let result = editor.apply_complete(dbg!(&operations)).await;
|
||||
let result = match editor.edit().await {
|
||||
Ok(editable_image) => editable_image.apply_complete(&operations).await,
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
match result {
|
||||
Err(err) if matches!(err.error(), glycin::Error::Canceled(_)) => {
|
||||
log::debug!("Computing edited image canceled");
|
||||
|
|
@ -362,9 +365,9 @@ mod imp {
|
|||
ErrorType::Loader,
|
||||
)
|
||||
}
|
||||
Ok(binary_data) => {
|
||||
Ok(edit) => {
|
||||
log::debug!("Saving edited image to '{}'", new_file.uri());
|
||||
match binary_data.get() {
|
||||
match edit.data().get() {
|
||||
Err(err) => {
|
||||
obj.window().show_error(
|
||||
&gettext("Failed to Save Image"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue