mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: image format
This commit is contained in:
parent
0766e37100
commit
4af52c74fb
2 changed files with 13 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::Result;
|
||||
use image::imageops::FilterType;
|
||||
use image::{imageops::FilterType, ImageFormat};
|
||||
use tokio::{fs, sync::mpsc};
|
||||
|
||||
use super::TaskOp;
|
||||
|
|
@ -68,10 +68,8 @@ impl Precache {
|
|||
};
|
||||
|
||||
let (w, h) = (PREVIEW.max_width, PREVIEW.max_height);
|
||||
if img.width() <= w && img.height() <= h {
|
||||
img.save(cache).ok();
|
||||
} else {
|
||||
img.resize(w, h, FilterType::Triangle).save(cache).ok();
|
||||
if img.width() > w || img.height() > h {
|
||||
img.resize(w, h, FilterType::Triangle).save_with_format(&cache, ImageFormat::Jpeg).ok();
|
||||
}
|
||||
self.sch.send(TaskOp::Adv(task.id, 1, 0))?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use std::process::Stdio;
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::{process::Command, select, sync::{mpsc, oneshot}};
|
||||
use tracing::trace;
|
||||
|
|
@ -44,9 +46,16 @@ impl Process {
|
|||
ProcessOp::Open(task) => {
|
||||
trace!("Open task: {:?}", task);
|
||||
if !task.block {
|
||||
let status = Command::new(&task.cmd)
|
||||
.args(&task.args)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.kill_on_drop(true)
|
||||
.status();
|
||||
|
||||
select! {
|
||||
_ = task.cancel.closed() => {},
|
||||
Ok(status) = Command::new(&task.cmd).args(&task.args).kill_on_drop(true).status() => {
|
||||
Ok(status) = status => {
|
||||
trace!("{} exited with {:?}", task.cmd, status);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue