Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect the user's image_alloc setting for the built-in ImageMagick previewer #2403

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions yazi-plugin/preset/plugins/magick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function M:preload(job)
"-auto-orient",
"JPG:" .. tostring(cache),
})
:env("MAGICK_MEMORY_LIMIT", rt.tasks.image_alloc)
:env("MAGICK_THREAD_LIMIT", 1)
:status()

Expand Down
13 changes: 12 additions & 1 deletion yazi-plugin/src/config/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use mlua::{IntoLua, Lua, LuaSerdeExt, SerializeOptions, Value};
use yazi_boot::ARGS;
use yazi_config::{MGR, PREVIEW, THEME};
use yazi_config::{MGR, PREVIEW, TASKS, THEME};

use crate::{Composer, url::Url};

Expand All @@ -19,6 +19,7 @@ impl<'a> Runtime<'a> {
b"mgr" => Self::mgr(lua)?,
b"plugin" => super::Plugin::compose(lua)?,
b"preview" => Self::preview(lua)?,
b"tasks" => Self::tasks(lua)?,
_ => return Ok(Value::Nil),
}
.into_lua(lua)
Expand Down Expand Up @@ -62,6 +63,16 @@ impl<'a> Runtime<'a> {
})
}

fn tasks(lua: &Lua) -> mlua::Result<Value> {
Composer::make(lua, 5, |lua, key| {
match key {
b"image_alloc" => lua.to_value_with(&TASKS.image_alloc, OPTS)?,
_ => return Ok(Value::Nil),
}
.into_lua(lua)
})
}

pub fn new(lua: &'a Lua) -> Self { Self { lua } }

// TODO: remove this
Expand Down
Loading