telescope-media-files.nvim icon indicating copy to clipboard operation
telescope-media-files.nvim copied to clipboard

Images are pixelated

Open rodude123 opened this issue 10 months ago • 5 comments

I'm using lunarvim and I have enabled this but images are pixelated in kitty. image I can share my wholej config if you'd like

lvim.builtin.telescope.on_config_done = function(telescope)
  pcall(telescope.load_extension, "media_files")
end
local previewers = require("telescope.previewers")

lvim.builtin.telescope.register_previewer = function(telescope)


    local new_maker = function(filepath, bufnr, opts)
      opts = opts or {}

      filepath = vim.fn.expand(filepath)
      job_id = vim.loop.spawn('kitty', {
        args = {'+kitten', 'icat', '--place', opts.x..'%', opts.y..'%', '--silent', filepath},
        detached = true
      }, function(code)
        -- command finished
      end)

      return bufnr
    end

    local get_command = function(filepath)
        return {
          "kitty",
          "+kitten", 
          "icat",
          "--silent",
          "--sacle",
          filepath
        }
    end


    telescope.extensions.media_files.previewer = previewers.new_termopen_previewer({
        get_bufnr = new_maker,
        get_command = get_command
    })

end

lvim.builtin.telescope.on_config_done = function(telescope)
  -- telescope.setup {
  --   defaults = {
  --       file_previewer = require('telescope.previewers').vim_buffer_cat.new,
  --   },  
    -- extensions = {
    --   media_files = {
    --     filetypes = {"png", "jpg", "mp4", "pdf", "gif"},
    --     file_previewer = require('telescope.previewers').ueberzug_maker({
    --         display_method = 'kitty'
    --     }),
    --     find_cmd = "fd"
    --   }
    -- }
  -- }
    local previewers = require('telescope.previewers')
    local new_maker = function(filepath, bufnr, opts)
      opts = opts or {}

      filepath = vim.fn.expand(filepath)
      job_id = vim.loop.spawn('kitty', {
        args = {'+kitten', 'icat', '--place', opts.x..'%', opts.y..'%', '--silent', filepath},
        detached = true
      }, function(code)
        -- command finished
      end)

      return bufnr
    end

    local get_command = function(filepath)
        return {
          "kitty",
          "+kitten", 
          "icat",
          "--silent",
          "--sacle",
          filepath
        }
    end

    telescope.setup {
      defaults = {
        file_previewer = require('telescope.previewers').vim_buffer_cat.new,

        media_files = {
          file_previewer = previewers.new_termopen_previewer({
            get_bufnr = new_maker,
            get_command = get_command
          })
        }
      },
        extensions = {
          media_files = {
            filetypes = {"png", "jpg", "mp4", "pdf", "gif"},
            find_cmd = "fd"
          }
        }
    }
    telescope.extensions.media_files.use_ueberzug = false
    telescope.extensions.media_files.previewer = previewers.new_termopen_previewer({
        get_bufnr = new_maker,
        get_command = get_command
    })
    telescope.load_extension("media_files") 
end

rodude123 avatar Sep 06 '23 21:09 rodude123

That's what I tried but same thing

rodude123 avatar Sep 06 '23 21:09 rodude123

duplicate of #46 I still haven't found a fix....

stove-jeebs avatar Sep 16 '23 22:09 stove-jeebs

Looking at the chafa website, it seems to me that this is expected behaviour.

EDIT: Actually, when running the chafa command inside kitty terminal, images show up normally.

kamack38 avatar Dec 12 '23 19:12 kamack38

This Neovim issue appears related: :term should forward unknown sequences to host

jchilders avatar Jan 05 '24 20:01 jchilders

all solutions I tried so far has this same issue of pixelated images, except for yazi that I found out recently.. from my long list of tested alternatives was the first one looking good under tmux

Hope we can have this fixed for telescope extensions .. would be really nice

rodhash avatar Mar 02 '24 14:03 rodhash