image.nvim
image.nvim copied to clipboard
Allow controlling "zoom" level, to proportionally increase image size
Some images may look small, especially on screens with high DPI (e.g retina). So it would be cool to control the image size by allowing one to zoom in.
+1 for this!
I did my own little solution for this, it more or less works, but with some unexpected behaviors. Give it a try!
local autocmd = vim.api.nvim_create_autocmd
local map = vim.keymap.set
autocmd("BufRead", {
group = "image.nvim",
callback = function(o)
local bufnr = o.buf
local images = image.get_images({ buffer = bufnr })
if #images ~= 1 then
return
end
local preview_image = images[1]
map("n", "+", function()
preview_image.image_width = preview_image.image_width * 1.25
preview_image.image_height = preview_image.image_height * 1.25
preview_image:render()
end, {
buffer = bufnr,
desc = "Zoom in image",
})
map("n", "_", function()
preview_image.image_width = preview_image.image_width / 1.25
preview_image.image_height = preview_image.image_height / 1.25
preview_image:render()
end, {
buffer = bufnr,
desc = "Zoom out image",
})
end,
})
Ha that's cool, we'll add a global scaling option as well!
Hi, I created a PR for this. I wonder if this works?
https://github.com/3rd/image.nvim/pull/252
@huntf-bitstrata thank you!