This commit is contained in:
sxyazi 2023-08-04 22:42:47 +08:00
parent 36bad9c4ed
commit dc371b782c
No known key found for this signature in database
2 changed files with 34 additions and 38 deletions

View file

@ -36,8 +36,7 @@ impl Image {
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.resize(w, h, FilterType::Triangle) img.resize(w, h, FilterType::Triangle).save_with_format(cache, ImageFormat::Jpeg)?;
.save_with_format(cache, ImageFormat::Jpeg)?;
} }
Ok::<(), Error>(()) Ok::<(), Error>(())
}); });
@ -47,10 +46,7 @@ impl Image {
#[inline] #[inline]
pub fn cache(path: &Path) -> PathBuf { pub fn cache(path: &Path) -> PathBuf {
format!( format!("/tmp/yazi/{:x}", Md5::new_with_prefix(path.to_string_lossy().as_bytes()).finalize())
"/tmp/yazi/{:x}",
Md5::new_with_prefix(path.to_string_lossy().as_bytes()).finalize()
)
.into() .into()
} }
} }