mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41: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 std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use image::imageops::FilterType;
|
use image::{imageops::FilterType, ImageFormat};
|
||||||
use tokio::{fs, sync::mpsc};
|
use tokio::{fs, sync::mpsc};
|
||||||
|
|
||||||
use super::TaskOp;
|
use super::TaskOp;
|
||||||
|
|
@ -68,10 +68,8 @@ impl Precache {
|
||||||
};
|
};
|
||||||
|
|
||||||
let (w, h) = (PREVIEW.max_width, PREVIEW.max_height);
|
let (w, h) = (PREVIEW.max_width, PREVIEW.max_height);
|
||||||
if img.width() <= w && img.height() <= h {
|
if img.width() > w || img.height() > h {
|
||||||
img.save(cache).ok();
|
img.resize(w, h, FilterType::Triangle).save_with_format(&cache, ImageFormat::Jpeg).ok();
|
||||||
} else {
|
|
||||||
img.resize(w, h, FilterType::Triangle).save(cache).ok();
|
|
||||||
}
|
}
|
||||||
self.sch.send(TaskOp::Adv(task.id, 1, 0))?;
|
self.sch.send(TaskOp::Adv(task.id, 1, 0))?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::process::Stdio;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::{process::Command, select, sync::{mpsc, oneshot}};
|
use tokio::{process::Command, select, sync::{mpsc, oneshot}};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
@ -44,9 +46,16 @@ impl Process {
|
||||||
ProcessOp::Open(task) => {
|
ProcessOp::Open(task) => {
|
||||||
trace!("Open task: {:?}", task);
|
trace!("Open task: {:?}", task);
|
||||||
if !task.block {
|
if !task.block {
|
||||||
|
let status = Command::new(&task.cmd)
|
||||||
|
.args(&task.args)
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.kill_on_drop(true)
|
||||||
|
.status();
|
||||||
|
|
||||||
select! {
|
select! {
|
||||||
_ = task.cancel.closed() => {},
|
_ = 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);
|
trace!("{} exited with {:?}", task.cmd, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue