diff --git a/yazi-plugin/preset/plugins/magick.lua b/yazi-plugin/preset/plugins/magick.lua index 185c7780..8d593c68 100644 --- a/yazi-plugin/preset/plugins/magick.lua +++ b/yazi-plugin/preset/plugins/magick.lua @@ -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() diff --git a/yazi-plugin/src/config/runtime.rs b/yazi-plugin/src/config/runtime.rs index a3482614..cace6e8e 100644 --- a/yazi-plugin/src/config/runtime.rs +++ b/yazi-plugin/src/config/runtime.rs @@ -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}; @@ -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) @@ -62,6 +63,16 @@ impl<'a> Runtime<'a> { }) } + fn tasks(lua: &Lua) -> mlua::Result { + Composer::make(lua, 10, |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