From 0b340b67d5621402c50de264d8bf82e9aa4e2759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 10 Dec 2024 07:45:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20failed=20to=20parse=20certain=20image=20?= =?UTF-8?q?dimensions=20for=20=C3=9Cberzug++=20backend=20(#2020)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- yazi-adapter/src/drivers/ueberzug.rs | 6 +++++- yazi-config/preset/README.md | 6 +++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4afa40c6..65030157 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,9 +360,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1397,9 +1397,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" [[package]] name = "libc" -version = "0.2.167" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libfuzzer-sys" @@ -2210,15 +2210,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ac6ad943..102a0550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ crossterm = { version = "0.28.1", features = [ "event-stream" ] } dirs = "5.0.1" futures = "0.3.31" globset = "0.4.15" -libc = "0.2.167" +libc = "0.2.168" md-5 = "0.10.6" mlua = { version = "0.10.2", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] } parking_lot = "0.12.3" diff --git a/yazi-adapter/src/drivers/ueberzug.rs b/yazi-adapter/src/drivers/ueberzug.rs index 7620af00..1fa60ed7 100644 --- a/yazi-adapter/src/drivers/ueberzug.rs +++ b/yazi-adapter/src/drivers/ueberzug.rs @@ -1,6 +1,7 @@ use std::{path::{Path, PathBuf}, process::Stdio}; use anyhow::{Result, bail}; +use image::ImageReader; use ratatui::layout::Rect; use tokio::{io::AsyncWriteExt, process::{Child, Command}, sync::mpsc::{self, UnboundedSender}}; use tracing::{debug, warn}; @@ -47,7 +48,10 @@ impl Ueberzug { }; let p = path.to_owned(); - let (w, h) = tokio::task::spawn_blocking(move || image::image_dimensions(p)).await??; + let (w, h) = tokio::task::spawn_blocking(move || { + ImageReader::open(p)?.with_guessed_format()?.into_dimensions() + }) + .await??; let area = Dimension::ratio() .map(|(r1, r2)| Rect { diff --git a/yazi-config/preset/README.md b/yazi-config/preset/README.md index a89966a4..a2982e4f 100644 --- a/yazi-config/preset/README.md +++ b/yazi-config/preset/README.md @@ -14,13 +14,13 @@ These files are already included with Yazi when you install the release, so you However, if you want to customize certain configurations: -- Create a `yazi.toml` in your config directory to override the settings in [`yazi-default.toml`][yazi-default], so either: +- Create a `yazi.toml` in your config directory to override certain settings in [`yazi-default.toml`][yazi-default], so either: - `~/.config/yazi/yazi.toml` on Unix-like systems - `C:\Users\USERNAME\AppData\Roaming\yazi\config\yazi.toml` on Windows -- Create a `keymap.toml` in your config directory to override the settings in [`keymap-default.toml`][keymap-default], so either: +- Create a `keymap.toml` in your config directory to override certain settings in [`keymap-default.toml`][keymap-default], so either: - `~/.config/yazi/keymap.toml` on Unix-like systems - `C:\Users\USERNAME\AppData\Roaming\yazi\config\keymap.toml` on Windows -- Create a `theme.toml` in your config directory to override the settings in [`theme-light.toml`][theme-light] and [`theme-dark.toml`][theme-dark], so either: +- Create a `theme.toml` in your config directory to override certain settings in [`theme-light.toml`][theme-light] and [`theme-dark.toml`][theme-dark], so either: - `~/.config/yazi/theme.toml` on Unix-like systems - `C:\Users\USERNAME\AppData\Roaming\yazi\config\theme.toml` on Windows