yazi: previews for `image/{heic,jxl,svg+xml}` mime with `magick` not working

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

kitty 0.34.1

Did you try the latest code to see if this problem got fixed?

Tried, but the problem still

yazi --debug output

Yazi
    Version: 0.2.5 (9a5b756 2024-06-25)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.2.5

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE: Some("tty")
    WAYLAND_DISPLAY : None
    DISPLAY         : Some(":1")

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bin/zsh")
    EDITOR             : Some("nvim")
    ZELLIJ_SESSION_NAME: None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "Neovim", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "Neovim", for_: None, spread: true })

tmux
    TMUX   : false
    Version: No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-25
    fzf              : 0.53.0
    fd               : 9.0.0
    rg               : 14.1.0
    chafa            : No such file or directory (os error 2)
    zoxide           : 0.9.4
    unar             : No such file or directory (os error 2)
    jq               : 1.7.1

Describe the bug

I can open image/{heic,jxl,svg+xml} files just fine with either <Enter> or <o> but previews with magick fail with the following error for each image:

  • ~/.local/state/yazi/yazi.log
ERROR yazi_scheduler::preload::prework: Preload task `magick` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

Expected Behavior

Previews for image/{heic,jxl,svg+xml} are working

To Reproduce

  1. Open yazi in a directory with image/{heic,jxl,svg+xml} files
  2. Highlight said files
  3. Preview isn’t working for any of them
  4. The error mentioned is written to ~/.local/state/yazi/yazi.log for each image

Configuration

[preview]
tab_size = 2
max_width = 600
max_height = 900
cache_dir = ""
image_filter = "triangle"
image_quality = 75
sixel_fraction = 15

[opener]
open = [{ run = 'xdg-open "$@"', desc = "Open" }]

[open]
rules = [
  { mime = "image/*", use = [
    "open",
    "reveal",
  ] },
]

[plugin]
preloaders = [
  { mime = "image/{heic,jxl,svg+xml}", run = "magick" },
]

Anything else?

Converting some image/{heic,jxl,svg+xml} files directly with magick from the terminal works fine, re-using the args used in https://github.com/sxyazi/yazi/blob/9a5b75662a4de9ed9ba2a6c949fbd5445b841096/yazi-plugin/preset/plugins/magick.lua#L23-L31

% magick --version
Version: ImageMagick 7.1.1-25 Q16 x86_64 21883 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo freetype heic jng jpeg jxl lcms ltdl pangocairo png rsvg tiff webp x xml zlib zstd
Compiler: gcc (13.2)

% file -bL --mime-type "sample.heic" "sample.jxl" "sample.svg"                                                       
image/heic
image/jxl
image/svg+xml

% magick "sample.heic" -density 200 -resize 600x900 -quality 75 -verbose "/tmp/yazi/sample.jpg"
sample.heic=>/tmp/yazi/sample.jpg HEIC 640x426=>600x399 600x399+0+0 8-bit sRGB 38638B 0.010u 0:00.003

% magick "sample.jxl" -density 200 -resize 600x900 -quality 75 -verbose "/tmp/yazi/sample.jpg"
sample.jxl=>/tmp/yazi/sample.jpg JXL 1800x800=>600x267 600x267+0+0 10-bit sRGB 11102B 0.010u 0:00.002

% magick "sample.svg" -density 200 -resize 600x900 -quality 75 -verbose "/tmp/yazi/sample.jpg"
sample.svg=>/tmp/yazi/sample.jpg SVG 64x64=>600x600 600x600+0+0 16-bit sRGB 14380B 0.030u 0:00.004

The /tmp/sample.jpg files can be opened/previewed just fine after the conversion.

Other images file types previews are working fine with image.lua plugin.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Should be fixed in https://github.com/sxyazi/yazi/pull/1213, please give it a try!

Thanks for the info, helped a lot!

This might be due to differences in magick versions - I’ll look into it.

This also fails in the terminal:

% magick -verbose -density 200 -resize 600x900 -quality 75 "sample.heic" "JPG:/tmp/yazi/bb246b7c98580c99631791c429c5acb0"
magick: no images found for operation `-resize' at CLI arg 3 @ error/operation.c/CLIOption/5479.

% echo $?                                                                                                       
1

But this works:

% magick "sample.heic" -verbose -density 200 -resize 600x900 -quality 75 "JPG:/tmp/yazi/bb246b7c98580c99631791c429c5acb0"
sample.heic=>/tmp/yazi/bb246b7c98580c99631791c429c5acb0 HEIC 640x426=>600x399 600x399+0+0 8-bit sRGB 38638B 0.030u 0:00.003

% echo $?
0

Maybe inverting the order in magick.lua would work (input/parameters/output instead of parameters/input/output)?

Also does it currently generate the target file e.g. /tmp/yazi/9a49dd5222d0e037890dee6b9ce2321b?

No, it doesn’t:

% file /tmp/yazi/bb246b7c98580c99631791c429c5acb0
/tmp/yazi/bb246b7c98580c99631791c429c5acb0: cannot open `/tmp/yazi/bb246b7c98580c99631791c429c5acb0' (No such file or directory)

% file /tmp/yazi/8016945d8567f40f607644b395598675                                                                             
/tmp/yazi/8016945d8567f40f607644b395598675: cannot open `/tmp/yazi/8016945d8567f40f607644b395598675' (No such file or directory)

% file /tmp/yazi/9a49dd5222d0e037890dee6b9ce2321b                                                                            
/tmp/yazi/9a49dd5222d0e037890dee6b9ce2321b: cannot open `/tmp/yazi/9a49dd5222d0e037890dee6b9ce2321b' (No such file or directory)

No, only args is needed, i.e.:

ya.err({
  "-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),
})