mirror of
https://github.com/sxyazi/yazi.git
synced 2024-09-11 10:26:35 +03:00
feat: SVG, HEIC, and JPEG XL preview support (#1050)
This commit is contained in:
parent
65afe6027a
commit
5a83577259
@ -1 +1 @@
|
||||
{"version":"0.2","flagWords":[],"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime"]}
|
||||
{"language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick"],"version":"0.2"}
|
@ -82,6 +82,9 @@ suppress_preload = false
|
||||
preloaders = [
|
||||
{ name = "*", cond = "!mime", run = "mime", multi = true, prio = "high" },
|
||||
# Image
|
||||
{ mime = "image/svg+xml", run = "magick" },
|
||||
{ mime = "image/heic", run = "magick" },
|
||||
{ mime = "image/jxl", run = "magick" },
|
||||
{ mime = "image/*", run = "image" },
|
||||
# Video
|
||||
{ mime = "video/*", run = "video" },
|
||||
@ -99,7 +102,9 @@ previewers = [
|
||||
# JSON
|
||||
{ mime = "application/json", run = "json" },
|
||||
# Image
|
||||
{ mime = "image/vnd.djvu", run = "noop" },
|
||||
{ mime = "image/svg+xml", run = "magick" },
|
||||
{ mime = "image/heic", run = "magick" },
|
||||
{ mime = "image/jxl", run = "magick" },
|
||||
{ mime = "image/*", run = "image" },
|
||||
# Video
|
||||
{ mime = "video/*", run = "video" },
|
||||
|
43
yazi-plugin/preset/plugins/magick.lua
Normal file
43
yazi-plugin/preset/plugins/magick.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache then
|
||||
return
|
||||
end
|
||||
|
||||
if self:preload() == 1 then
|
||||
ya.image_show(cache, self.area)
|
||||
ya.preview_widgets(self, {})
|
||||
end
|
||||
end
|
||||
|
||||
function M:seek() end
|
||||
|
||||
function M:preload()
|
||||
local cache = ya.file_cache(self)
|
||||
if not cache or fs.cha(cache) then
|
||||
return 1
|
||||
end
|
||||
|
||||
local child, code = Command("convert"):args({
|
||||
"-density",
|
||||
"200",
|
||||
"-resize",
|
||||
string.format("%dx%d^", PREVIEW.max_width, PREVIEW.max_height),
|
||||
"-quality",
|
||||
tostring(PREVIEW.image_quality),
|
||||
tostring(self.file.url),
|
||||
"JPG:" .. tostring(cache),
|
||||
}):spawn()
|
||||
|
||||
if not child then
|
||||
ya.err("spawn `convert` command returns " .. tostring(code))
|
||||
return 0
|
||||
end
|
||||
|
||||
local status = child:wait()
|
||||
return status and status:success() and 1 or 2
|
||||
end
|
||||
|
||||
return M
|
@ -44,6 +44,7 @@ impl Loader {
|
||||
"fzf" => include_bytes!("../../preset/plugins/fzf.lua"),
|
||||
"image" => include_bytes!("../../preset/plugins/image.lua"),
|
||||
"json" => include_bytes!("../../preset/plugins/json.lua"),
|
||||
"magick" => include_bytes!("../../preset/plugins/magick.lua"),
|
||||
"mime" => include_bytes!("../../preset/plugins/mime.lua"),
|
||||
"pdf" => include_bytes!("../../preset/plugins/pdf.lua"),
|
||||
"video" => include_bytes!("../../preset/plugins/video.lua"),
|
||||
|
Loading…
Reference in New Issue
Block a user