mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Conditional arguments
This commit is contained in:
parent
f2f837800e
commit
5306aad658
1 changed files with 17 additions and 12 deletions
|
|
@ -24,23 +24,28 @@ function M:preload(job)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd = Command("magick"):args {
|
local cmd = Command("magick")
|
||||||
tostring(job.file.url),
|
if job.args.flatten then
|
||||||
"-auto-orient",
|
cmd = cmd:arg("-flatten")
|
||||||
"-strip",
|
end
|
||||||
"-sample",
|
|
||||||
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
|
||||||
"-flatten",
|
|
||||||
"-quality",
|
|
||||||
rt.preview.image_quality,
|
|
||||||
"JPG:" .. tostring(cache),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
cmd = cmd:args { tostring(job.file.url), "-auto-orient", "-strip" }
|
||||||
|
if job.mime:find("/svg%+xml") then
|
||||||
|
cmd = cmd:args { "-density", 200 }
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd = cmd:env("MAGICK_THREAD_LIMIT", 1)
|
||||||
if rt.tasks.image_alloc > 0 then
|
if rt.tasks.image_alloc > 0 then
|
||||||
cmd = cmd:env("MAGICK_MEMORY_LIMIT", rt.tasks.image_alloc)
|
cmd = cmd:env("MAGICK_MEMORY_LIMIT", rt.tasks.image_alloc)
|
||||||
end
|
end
|
||||||
|
|
||||||
local status, err = cmd:env("MAGICK_THREAD_LIMIT", 1):status()
|
-- stylua: ignore
|
||||||
|
local status, err = cmd:args {
|
||||||
|
"-sample", string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
|
||||||
|
"-quality", rt.preview.image_quality,
|
||||||
|
string.format("JPG:%s", cache),
|
||||||
|
}:status()
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
return status.success
|
return status.success
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue