-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Opening a markdown file that references a multi-page PDF crashes with an error from magick_cli.lua.
Crash details
Error executing callback:
...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:36: identify: unable to open image '/var/folders/pv/tgp_ylrd4dbfs93hkd5fp8d80000gn/T/nvim.devin/OY8ksj/0/MTAwMDozOjQz
OjVhNDVjOGU5YWJlZGMxNjZjNGNjNzBiYWZiMjNhZDNiM2EyMWEwYzdmNWZhODNiMWUzNGQyYTEwOGJmZDI4MzE=-source.png': No such file or directory @ error/blob.c/OpenBlob/3596.
stack traceback:
[C]: in function 'error'
...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:36: in function <...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:35>
[C]: in function 'wait'
...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:50: in function 'get_format'
...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:100: in function 'get_dimensions'
...es/nvim.symconfig/plugged/image.nvim/lua/image/image.lua:330: in function <...es/nvim.symconfig/plugged/image.nvim/lua/image/image.lua:241>
[C]: in function 'pcall'
...ymconfig/plugged/image.nvim/lua/image/utils/document.lua:202: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
[C]: in function 'wait'
...g/plugged/image.nvim/lua/image/processors/magick_cli.lua:85: in function 'convert_to_png'
...es/nvim.symconfig/plugged/image.nvim/lua/image/image.lua:326: in function <...es/nvim.symconfig/plugged/image.nvim/lua/image/image.lua:241>
[C]: in function 'pcall'
...ymconfig/plugged/image.nvim/lua/image/utils/document.lua:202: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
The root cause is:
magic.luarecognizes PDFs as images- this causes image.nvim to attempt to render them
convert_to_pngdoesn't handle multi-page documents the way it handles multi-frame GIFs (i.e. truncating to the first page- imagemagick CLI creates separate
...-1.png,...-2.png, etc. files for each page of the PDF - therefore
image.lua:330expects a single file at the exact output path (output-source.png)
Steps to Reproduce
- Create a markdown file referencing a multi-page PDF:

- Open the markdown file in neovim with image.nvim enabled
Suggested Fix
I'd suggest removing pdf from image_signatures in magic.lua:15 so that is_image returns false for PDFs and they are skipped entirely, based on lack of desire to support PDFs from #338.
Truncating to the first page like we truncate to the first frame of GIFs might be a low lift way to have extremely basic support for PDFs.
As a workaround I'm returning nil for paths with the PDF file extension in my resolve_image_path.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels