mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: respect the user's image_filter setting for the preset magick previewer (#3286)
This commit is contained in:
parent
ff5f656a31
commit
440e67164a
8 changed files with 31 additions and 38 deletions
|
|
@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
||||||
- Port several widespread GUI keys to the input component ([#2849])
|
- Port several widespread GUI keys to the input component ([#2849])
|
||||||
- Support invalid UTF-8 paths throughout the codebase ([#2884], [#2889], [#2890], [#2895], [#3023])
|
- Support invalid UTF-8 paths throughout the codebase ([#2884], [#2889], [#2890], [#2895], [#3023])
|
||||||
- Allow upgrading only specific packages with `ya pkg` ([#2841])
|
- Allow upgrading only specific packages with `ya pkg` ([#2841])
|
||||||
|
- Respect the user's `image_filter` setting for the preset `magick` previewer ([#3286])
|
||||||
- Allow custom mouse click behavior for individual files ([#2925])
|
- Allow custom mouse click behavior for individual files ([#2925])
|
||||||
- Display newlines in input as spaces to improve readability ([#2932])
|
- Display newlines in input as spaces to improve readability ([#2932])
|
||||||
- Fill in error messages if preview fails ([#2917])
|
- Fill in error messages if preview fails ([#2917])
|
||||||
|
|
@ -1530,3 +1531,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
||||||
[#3264]: https://github.com/sxyazi/yazi/pull/3264
|
[#3264]: https://github.com/sxyazi/yazi/pull/3264
|
||||||
[#3268]: https://github.com/sxyazi/yazi/pull/3268
|
[#3268]: https://github.com/sxyazi/yazi/pull/3268
|
||||||
[#3271]: https://github.com/sxyazi/yazi/pull/3271
|
[#3271]: https://github.com/sxyazi/yazi/pull/3271
|
||||||
|
[#3286]: https://github.com/sxyazi/yazi/pull/3286
|
||||||
|
|
|
||||||
22
Cargo.lock
generated
22
Cargo.lock
generated
|
|
@ -2027,15 +2027,6 @@ dependencies = [
|
||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "malloc_buf"
|
|
||||||
version = "0.0.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchers"
|
name = "matchers"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -2334,15 +2325,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "objc"
|
|
||||||
version = "0.2.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
|
|
||||||
dependencies = [
|
|
||||||
"malloc_buf",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2"
|
name = "objc2"
|
||||||
version = "0.6.3"
|
version = "0.6.3"
|
||||||
|
|
@ -4891,7 +4873,7 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"objc",
|
"objc2",
|
||||||
"yazi-macro",
|
"yazi-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -4947,7 +4929,7 @@ dependencies = [
|
||||||
"foldhash 0.2.0",
|
"foldhash 0.2.0",
|
||||||
"hashbrown 0.16.0",
|
"hashbrown 0.16.0",
|
||||||
"libc",
|
"libc",
|
||||||
"objc",
|
"objc2",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ indexmap = { version = "2.12.0", features = [ "serde" ] }
|
||||||
libc = "0.2.177"
|
libc = "0.2.177"
|
||||||
lru = "0.16.2"
|
lru = "0.16.2"
|
||||||
mlua = { version = "0.11.4", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serde" ] }
|
mlua = { version = "0.11.4", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serde" ] }
|
||||||
objc = "0.2.7"
|
objc2 = "0.6.3"
|
||||||
ordered-float = { version = "5.1.0", features = [ "serde" ] }
|
ordered-float = { version = "5.1.0", features = [ "serde" ] }
|
||||||
parking_lot = "0.12.5"
|
parking_lot = "0.12.5"
|
||||||
paste = "1.0.15"
|
paste = "1.0.15"
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@ libc = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation-sys = { workspace = true }
|
core-foundation-sys = { workspace = true }
|
||||||
objc = { workspace = true }
|
objc2 = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::{ffi::{CStr, OsStr, OsString, c_char, c_void}, mem::ManuallyDrop, os::u
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use core_foundation_sys::{base::{CFRelease, TCFTypeRef}, dictionary::{CFDictionaryGetValueIfPresent, CFDictionaryRef}, string::CFStringRef};
|
use core_foundation_sys::{base::{CFRelease, TCFTypeRef}, dictionary::{CFDictionaryGetValueIfPresent, CFDictionaryRef}, string::CFStringRef};
|
||||||
use objc::{msg_send, runtime::Object, sel, sel_impl};
|
use objc2::{msg_send, runtime::AnyObject};
|
||||||
|
|
||||||
use super::cf_string::CFString;
|
use super::cf_string::CFString;
|
||||||
|
|
||||||
|
|
@ -30,13 +30,13 @@ impl CFDict {
|
||||||
pub fn bool(&self, key: &str) -> Result<bool> {
|
pub fn bool(&self, key: &str) -> Result<bool> {
|
||||||
let value = self.value(key)?;
|
let value = self.value(key)?;
|
||||||
#[allow(unexpected_cfgs)]
|
#[allow(unexpected_cfgs)]
|
||||||
Ok(unsafe { msg_send![value as *const Object, boolValue] })
|
Ok(unsafe { msg_send![value as *const AnyObject, boolValue] })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn integer(&self, key: &str) -> Result<i64> {
|
pub fn integer(&self, key: &str) -> Result<i64> {
|
||||||
let value = self.value(key)?;
|
let value = self.value(key)?;
|
||||||
#[allow(unexpected_cfgs)]
|
#[allow(unexpected_cfgs)]
|
||||||
Ok(unsafe { msg_send![value as *const Object, longLongValue] })
|
Ok(unsafe { msg_send![value as *const AnyObject, longLongValue] })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn os_string(&self, key: &str) -> Result<OsString> {
|
pub fn os_string(&self, key: &str) -> Result<OsString> {
|
||||||
|
|
@ -44,10 +44,10 @@ impl CFDict {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path_buf(&self, key: &str) -> Result<PathBuf> {
|
pub fn path_buf(&self, key: &str) -> Result<PathBuf> {
|
||||||
let url = self.value(key)? as *const Object;
|
let url = self.value(key)? as *const AnyObject;
|
||||||
#[allow(unexpected_cfgs)]
|
#[allow(unexpected_cfgs)]
|
||||||
let cstr: *const c_char = unsafe {
|
let cstr: *const c_char = unsafe {
|
||||||
let nss: *const Object = msg_send![url, path];
|
let nss: *const AnyObject = msg_send![url, path];
|
||||||
msg_send![nss, UTF8String]
|
msg_send![nss, UTF8String]
|
||||||
};
|
};
|
||||||
Ok(OsStr::from_bytes(unsafe { CStr::from_ptr(cstr) }.to_bytes()).into())
|
Ok(OsStr::from_bytes(unsafe { CStr::from_ptr(cstr) }.to_bytes()).into())
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ windows-sys = { version = "0.61.2", features = [ "Win32_Storage_FileSystem" ] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation-sys = { workspace = true }
|
core-foundation-sys = { workspace = true }
|
||||||
objc = { workspace = true }
|
objc2 = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
trash = "5.2.5"
|
trash = "5.2.5"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::{ffi::{CStr, CString, OsString, c_void}, mem, os::unix::{ffi::OsStringE
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use core_foundation_sys::{array::CFArrayRef, base::{CFRelease, kCFAllocatorDefault}, runloop::{CFRunLoopGetCurrent, CFRunLoopRun, kCFRunLoopDefaultMode}};
|
use core_foundation_sys::{array::CFArrayRef, base::{CFRelease, kCFAllocatorDefault}, runloop::{CFRunLoopGetCurrent, CFRunLoopRun, kCFRunLoopDefaultMode}};
|
||||||
use libc::{c_char, mach_port_t};
|
use libc::{c_char, mach_port_t};
|
||||||
use objc::{msg_send, runtime::Object, sel, sel_impl};
|
use objc2::{msg_send, runtime::AnyObject};
|
||||||
use scopeguard::defer;
|
use scopeguard::defer;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use yazi_ffi::{CFDict, CFString, DADiskCopyDescription, DADiskCreateFromBSDName, DARegisterDiskAppearedCallback, DARegisterDiskDescriptionChangedCallback, DARegisterDiskDisappearedCallback, DASessionCreate, DASessionScheduleWithRunLoop, IOIteratorNext, IOObjectRelease, IORegistryEntryCreateCFProperty, IOServiceGetMatchingServices, IOServiceMatching};
|
use yazi_ffi::{CFDict, CFString, DADiskCopyDescription, DADiskCreateFromBSDName, DARegisterDiskAppearedCallback, DARegisterDiskDescriptionChangedCallback, DARegisterDiskDisappearedCallback, DASessionCreate, DASessionScheduleWithRunLoop, IOIteratorNext, IOObjectRelease, IORegistryEntryCreateCFProperty, IOServiceGetMatchingServices, IOServiceMatching};
|
||||||
|
|
@ -161,7 +161,7 @@ impl Partitions {
|
||||||
defer! { unsafe { CFRelease(property) } };
|
defer! { unsafe { CFRelease(property) } };
|
||||||
|
|
||||||
#[allow(unexpected_cfgs)]
|
#[allow(unexpected_cfgs)]
|
||||||
let cstr: *const c_char = unsafe { msg_send![property as *const Object, UTF8String] };
|
let cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };
|
||||||
Ok(if cstr.is_null() {
|
Ok(if cstr.is_null() {
|
||||||
bail!("Invalid value for the name property");
|
bail!("Invalid value for the name property");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,26 @@ function M:preload(job)
|
||||||
|
|
||||||
local cmd = M.with_limit()
|
local cmd = M.with_limit()
|
||||||
if job.args.flatten then
|
if job.args.flatten then
|
||||||
cmd = cmd:arg("-flatten")
|
cmd:arg("-flatten")
|
||||||
|
end
|
||||||
|
cmd:arg { tostring(job.file.url), "-auto-orient", "-strip" }
|
||||||
|
|
||||||
|
local size = string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height)
|
||||||
|
if rt.preview.image_filter == "nearest" then
|
||||||
|
cmd:arg { "-sample", size }
|
||||||
|
elseif rt.preview.image_filter == "catmull-rom" then
|
||||||
|
cmd:arg { "-filter", "catrom", "-thumbnail", size }
|
||||||
|
elseif rt.preview.image_filter == "lanczos3" then
|
||||||
|
cmd:arg { "-filter", "lanczos", "-thumbnail", size }
|
||||||
|
elseif rt.preview.image_filter == "gaussian" then
|
||||||
|
cmd:arg { "-filter", "gaussian", "-thumbnail", size }
|
||||||
|
else
|
||||||
|
cmd:arg { "-filter", "triangle", "-thumbnail", size }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stylua: ignore
|
cmd:arg { "-quality", rt.preview.image_quality }
|
||||||
cmd = cmd:arg {
|
|
||||||
tostring(job.file.url), "-auto-orient", "-strip",
|
|
||||||
"-sample", string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
|
||||||
"-quality", rt.preview.image_quality,
|
|
||||||
}
|
|
||||||
if job.args.bg then
|
if job.args.bg then
|
||||||
cmd = cmd:arg { "-background", job.args.bg, "-alpha", "remove" }
|
cmd:arg { "-background", job.args.bg, "-alpha", "remove" }
|
||||||
end
|
end
|
||||||
|
|
||||||
local status, err = cmd:arg(string.format("JPG:%s", cache)):status()
|
local status, err = cmd:arg(string.format("JPG:%s", cache)):status()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue