[fractal] session: Use image crate to get image metadata



commit e8c3728a95230eecd92470c084419560d8a4d072
Author: Kévin Commaille <zecakeh tedomum fr>
Date:   Mon Oct 3 21:17:53 2022 +0200

    session: Use image crate to get image metadata

 src/utils/media.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/utils/media.rs b/src/utils/media.rs
index dfc08ca20..f0d16b371 100644
--- a/src/utils/media.rs
+++ b/src/utils/media.rs
@@ -3,7 +3,7 @@
 use std::{cell::Cell, sync::Mutex};
 
 use gettextrs::gettext;
-use gtk::{gdk_pixbuf, gio, prelude::*};
+use gtk::{gio, prelude::*};
 use matrix_sdk::attachment::{BaseAudioInfo, BaseImageInfo, BaseVideoInfo};
 use ruma::events::room::MediaSource;
 
@@ -74,9 +74,12 @@ pub async fn get_image_info(file: &gio::File) -> BaseImageInfo {
         None => return info,
     };
 
-    if let Ok(Some((_format, w, h))) = gdk_pixbuf::Pixbuf::file_info_future(path).await {
-        info.width = Some((w as u32).into());
-        info.height = Some((h as u32).into());
+    if let Some((w, h)) = image::io::Reader::open(path)
+        .ok()
+        .and_then(|reader| reader.into_dimensions().ok())
+    {
+        info.width = Some(w.into());
+        info.height = Some(h.into());
     }
 
     info


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]